HungryProton / scatter

Godot engine addon to randomly fill an area with props or other scenes
MIT License
2.17k stars 96 forks source link

Add option for basic multiplayer sync #168

Open PieKing1215 opened 1 year ago

PieKing1215 commented 1 year ago

(needed this for a project so figured I'd PR in case this is something you want :) )

Adds a new "Multiplayer Sync" option (false by default) on ProtonScatter node, which if enabled will sync the scatter output transforms from the multiplayer authority to clients

More specifically calls to these functions are synced via rpc:

Tested in Godot 4.1.1 (in an unreleased project) Might be worth making a dedicated test setup, idk how thorough you want to be

Demo (left is server with enabled field being toggled, right is client):

https://github.com/HungryProton/scatter/assets/13819558/b2b1e5af-ee76-4653-88f3-6f5c7cd5bc70

Some notes:

HungryProton commented 12 months ago

Hey, sorry for the delay. I don't know if scatter is really supposed to handle multiplayer at all. As long as you use the same seed on both sides, the results should be identical. (If they're not, that's an issue I need to fix)

I'm not familiar with multiplayer, but if you really need to drive it from the network, I would make it a separate node. (Added under a ScatterNode, like the ScatterItem nodes):

Basically, moving the multiplayer_call method to its own node, along with all the multiplayer features. Makes it easier to maintain (the scatter nodes don't know about multiplayer but still work as usual) and it doesn't cause conflicts with future updates.