godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

MutiplayerSpawner not accepting any callables for custom spawn function #91803

Closed kylemiller3 closed 6 months ago

kylemiller3 commented 6 months ago

Tested versions

Godot v4.2.1 [b09f793f5]

System information

Godot v4.2.1.stable - macOS 14.4.1 - Vulkan (Forward+) - integrated Apple M2 - Apple M2 (8 Threads)

Issue description

I want to use a custom spawn function with mutliplayer spawner but it always spawns a null node using custom function

image

Steps to reproduce

Join a multiplayer session and try to use a custom function to spawn on the authority

    spawner.set_spawn_function(func() -> Node: return Node.new())
    spawner.spawn()

I think should work but does not.

Minimal reproduction project (MRP)

Bug.zip

AThousandShips commented 6 months ago

It has to take one method, as per the documentation

So you should do:

spawner.set_spawn_function(func(_data) -> Node: return Node.new())
spawner.spawn()

To make this a bit easier to debug if someone makes this mistake (and don't read the docs) we could make it display the error from the call

kylemiller3 commented 6 months ago

That's interesting. My main project actually did have the first parameter used (it sent a string) and still got the message. Let me recheck.

kylemiller3 commented 6 months ago

image Unfortunately, I am still getting this problem

AThousandShips commented 6 months ago

Have you set it on all clients? Please upload an updated project id the original MRP contained the invalid function

Also please try with a normal method instead of a lambda

Please also try with a supported version like 4.2.2, 4.2.1 is not supported

kylemiller3 commented 6 months ago

Thank you I did not set the function on all clients which was the cause of my error! I might have missed that in the docs.