Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiplayerSpawner can only spawn one of any type of PackedScene (is this a bug or intentional feature?) #91881

Closed
RichardEllicott opened this issue May 12, 2024 · 6 comments

Comments

@RichardEllicott
Copy link

Tested versions

using version 4.22.... this bug/feature has always existed as far as i recall back to 4.0

System information

windows 10

Issue description

sorry i can't tell if this is a bug or a feature do to lack of documentation

when i use the MultiplayerSpawner, i can only spawn one of each type of scene... so one type of bullet, one type of player

Steps to reproduce

when i use the MultiplayerSpawner, i follow as many instructions as i can possibly find... including examples.

parts were undocumented like i had to add chid to the spawner itself, not it's spawn path.... when i add the child to the Spawner on the server, the client also does copy the spawn

however the name of the spawned object is the same as the orginal scene, and never changes... so adding another one on it will be say

DirtBlock1, DirtBlock2 (auto renamed by godot)

on the client, only DirtBlock1 will spawn

so please confirm is this a feature? is the MultiplayerSpawner limited this way as i need to get right on an code an alternative if so as i need to spawn multiple bullets.... it seems worth mentioning to prospective users on the docs... warning this only supports one of any type of object

Minimal reproduction project (MRP)

test_multiplayer_spawn.zip

@Protowalker
Copy link

You need to add the child to the spawn path, not the spawner; I'm not sure why you're having that behavior. Also, your MRP should be a whole project rather than just a script so we can get the full context.

What I can say is that it looks like in your script you override spawn_function and then call spawn manually. You only need to do this if you need to do a custom spawn based on some sort of arbitrary data; by default, just adding the entity as a child of the spawn path will replicate it on all clients.

You can absolutely have multiple instances of a packed scene from a MultiplayerSpawner, I think there's a bug in your code that's causing issues.

@RichardEllicott
Copy link
Author

RichardEllicott commented May 13, 2024

You need to add the child to the spawn path, not the spawner; I'm not sure why you're having that behavior. Also, your MRP should be a whole project rather than just a script so we can get the full context.

What I can say is that it looks like in your script you override spawn_function and then call spawn manually. You only need to do this if you need to do a custom spawn based on some sort of arbitrary data; by default, just adding the entity as a child of the spawn path will replicate it on all clients.

You can absolutely have multiple instances of a packed scene from a MultiplayerSpawner, I think there's a bug in your code that's causing issues.

i have tried both, actually no if you add it to the "spawn path" it doesn't work (i will tidy my example next coding round and make it one package people can just run)

no i don't call spawn manually... i have just tried everyway.... have you used this spawner in your own project and are able to achieve the behaviour of multiple spawns? (it would be nice to get a reply from someone who has sucessfully used the object)

all examples that i have found do not support multiple objects, so the bomberman demo for example has only one of the bomb per a player

you "think it's a bug in my code" but this doesn't help me as if i knew what exactly i'm doing wrong... the docs are very very poor, so for example you say "you need to add the child to the spawn path".... by testing i found that not to be the case..... the code actually works if you add to the spawner not the spawn path..... something i discovered by complete accident

is the author of the object available? this would be surely the easiest way to confirm the objects current limitations and behaviour... a lot of the info i'm trying to work from is here:
https://godotengine.org/article/multiplayer-in-godot-4-0-scene-replication/

so i think fabio wrote it

@RichardEllicott
Copy link
Author

RichardEllicott commented May 13, 2024

i'm also going to make a better minimal reproduction project... one that someone can just load twice then press some buttons

it is difficult to make a reproduction for this due to network part.... it's gonna end up with multiple parts and an autoload

i was hoping for a simple confirmation the Spawner has this limitation... as upong testing it, i find it doesn't send the name accross to the network........ the multiplayer in Godot needs the same names to syncronise nodes

since it needs the same names, and it doesn't send that name it uses the name that is inside the .tscn file (the root node name)..... i assume it's a known limitation so far (and have been making my own object for my personal project instead, which actually generates unique names)

@Protowalker
Copy link

This is definitely not a limitation of the Node currently. I'm using it in my project here:
https://github.com/Protowalker/3v3-shooter/blob/main/Components%2FWorld%2Fworld.gd#L35

Make sure the code to spawn the entity is only being called on the authority and make sure that the scene is in the MultiplayerSpawner's list of allowed scenes.

@RichardEllicott
Copy link
Author

RichardEllicott commented May 13, 2024

thanks for the example i will work through that, we can shut the ticket if required as if your project here is spawning as it is more than one player and bullet, of the same type of scene, it must be something i'm doing

i do use a different pattern to the "preload", i instead will have a variable on my node:

var packed_scene: PackedScene

and i will set it in the editor.... i assume this is fine, this is the same (inside the packed scene, it still has the same resource_path).... it fails i'll test it the other way anyway

@RichardEllicott
Copy link
Author

RichardEllicott commented May 13, 2024

okay thanks i can confirm this is all my missunderstanding, i followed your example and it was how i was handling the naming, i was expecting when i add it and it went say DirtBlock1, DirtBlock2... automaticly, when i was supposed to set the name in advance and make it unique (so i can either count numbers here or make some random name i think)... so extra testing i got it working normally

closing thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants