Kehom / GodotAddonPack

A collection of pure GDScript addons for Godot
http://kehomsforge.com
MIT License
183 stars 15 forks source link

Network: Reparenting spawned nodes #2

Closed croxis closed 4 years ago

croxis commented 4 years ago

I'm new to godot, so of course I do the sensible thing and jump right into making a persistent network game!

I'm making a sci-fi ship-crew game where players are person-like avatars (Kinematic) inside a ship (Ridgedbody). The server is always running so players and ships will be spawning/despawning as they log in and out. There will be an arbitrary number of ships and players.

Ideally I would like the player avatar to be a child node of the ship, however the register_spawner function seems to requires a hard-coded node to spawn in.

If I have a PlayerCharacter spawn node, will the network addon allow me to reparent without the system breaking? Or is there a better way for me to go about this?

Kehom commented 4 years ago

Hi there. That's actually an interesting use case I didn't think of when designing the entire system.

That said, the re-parenting should work. Internally it uses the unique ID to locate the corresponding reference to the node. Since re-parenting does not change the references, the internal data remains valid meaning that the networking system will still locate the correct nodes.

I'm now gauging some ideas and if believe any of them is "better" than just re-parenting the spawned node then I will incorporate the functionality into the system.