Trying my hand at networking and am having some trouble getting rigid bodies synced across clients The code I have so far is:

extends RigidBody

func _integrate_forces(state):
	if get_tree().is_network_server():
		rpc_unreliable("update_pos_rot", translation, rotation)

puppet func update_pos_rot(pos, rot):
	translation = pos
	rotation = rot

Now this kinda works, the position and collisions are synced pretty well but the host has to interact with the rigid body first for some reason as if he does not, the client's rigid body will act as if it is not being synced at all. Probably just some lack of understanding on my part but any help would be greatly appreciated.

This will only work if the server makes changes, because only the server is calling rpc due to your condition and only non-servers are receiving due to the puppet condition. But it does depend on your architecture, if you have all your other stuff make changes on the server then this is the correct code.

Otherwise, assuming integrate forces is called on actual changes and not every tick, you might want to change it to this:

    extends RigidBody

    func _integrate_forces(state):

            rpc_unreliable("update_pos_rot", translation, rotation)

    remote func update_pos_rot(pos, rot):

        translation = pos

        rotation = rot

Also you might want a headless (i.e. no game screen and only a little input in the form of terminal commands) host on a rented server if you don't want to require players to port forward, and it might be harder to switch to that later.

5 days later

ah that makes sense thank you very much got confused a bit with the function call types

7 months later