Missing something in multiplayer synchronization logic

Godot Version

4.4.stable.mono

Question

What am I missing in this multiplayer synchronization?

Context

I am working on the online multiplayer part of my game where I have a host and a client. Both are players (pvp). I am using multiplayer spawner, synchronizer and rpc.

player.gd collision detection:
Here I am detecting collision using Area3D node on player and calling hit_the_ball function for hitting the collided ball.

Shooting the ball on input from user:
Here I am taking user input (from line 90). Then instantiating the ball and giving it impulse.

Problem:
When Host player shoots the ball and it collides with the client, then ball hit by the client is seen on the host side but not on the client side.

This video guided me: YT Video

Where is the synchronization breaking? and why?

Could it be that the hit_impulse is local to the users and therefore the ball on the client-side doesnt have the hit-impulse value of the host-side? This would mean the balls exists on the client, but it doesnt move

It might be but I have just started learning to set up multiplayer so I am getting confused on how to fix it.
I had already added the hit_impulse property in the MultiplayerSynchronizer node of player.

I guess the rpc call needs some changes or some additions?

Fixed it!
Just had to replace this

hit_the_ball.rpc_id(body.get_multiplayer_authority(), body.get_path())

with this

hit_the_ball.rpc(body.get_path())

2 Likes