Hello, I can be said as a newbie in game development. I am making a third person shooter game using netcode for gameobjects. My characters using animation rigging to aim, shoot and other animations etc. However, a client and a host does not see each other in a synchronized way. I tried to make their values set by hand using server & client RPCs to make sure that, all of them are synchronized. But still they are not synchronized. What shall I do, this is also my first multiplayer game I am open to every possible advice.
A code sample for my setting rig values:
I am calling this method, using a server and a client rpc to make sure that all players’ rig values are synchronized with respect to current animation. However, they are still see each other in odd rotations & poses.
They never will. You don’t actually want to sync animation and bone positions across the network because then there’ll be horrible delays on everything. Movement and animation need to feel sharp and responsive so they are done client-side instantly and then propagated to the server and other clients, but nobody else will see the movement and animation exactly as they are on the person who did it.
The trick to putting a gun in the player’s hand and syncing the position up for all observers is that each observer needs to be allowed to move it itself. You don’t actually use any networking for syncing the position and animation of the gun, the netcode only handles telling the clients that player X equipped/unequipped the gun and then each player prefab needs a script that handles putting the equipped gun in the hand. Not a networkbehaviour, a regular old monobehaviour. Basically take all the networking out of the actual position and animation of the gun.
If you need to have the animations synced because you’re using the position of the gun to do shooting, you’ll have to fake it. The client who shoots the gun is the only person who accurately knows what way it’s supposed to be pointing, so they have to send that info to the server when the gun is fired and then everyone gets told a bullet is fired from the gun toward target y. This opens the game up to exploits because the client is in charge of bullet trajectories, but there’s no other option that feels good to play.