#Synching Movement / Anims
1 messages · Page 1 of 1 (latest)
well isn't that just a transform that is synced with the server and the other players?
We do that onMove / onRotate we just send an update to the server if the movement is above a specific threshold.
regarding Animations how would we do that? we don't want to make it super complicated, this is just a small school project to show that it is indeed possible to use gRPC for a Game.
So we just want to sync walking animations with the other clients, how do we do that?
I've never used gRPC but you can send Animator.StringToHash and probably a playback time to keep everything in sync. Its a non trival problem
You can deep dive into the NGO network animator here
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/develop/com.unity.netcode.gameobjects/Components/NetworkAnimator.cs
but how exactly do I then "play" the animation correctly.
when I move, I send a moveupdate containing xyz and yaw and pitch. this moveupdate gets broadcasted to all players, so they can update the player. Do I then just set the transform of the player and start the animation? when do I know when to stop it again?
The easiest way is probably to just handle the animations locally. When a new position comes in set the Speed parameter for the Animator and let it handle itself
that is a good idea.
I am having a bit of a problem and I am not too sure where that comes from.
So current progress: 2 Players join the servers, 2 player prefabs get instatiated. The Problem is that if I move using wasd the other player moves too. I am guessing that I have some kind of bug in my Movement system: https://paste.teamhelios.dev/pTWk3V9Lpx
After a bit of investigation I also noticed that there is some kind of problem when instatiating the player prefab.
After the second player joins both Players have the same Player
Player 1 only controls his own Player. but Player 2 controls both
You'll need to disable the player move component on your remove players or otherwise exit the update early if is not the local player object
Yea that should solve the issue for the movement, should I do the same for the camera and just remove it when instantiating?
regarding animating the movement:
Currently I am sending a move packet (xyz and yaw + pitch) for each movement a player does.
when applying the movement should I just set the velocity to that direction and trigger the movement animation?
The camera should not be networked. There can only be one active camera in the scene.
Movement will depend on your game. But also you'll run into issues if you are trying to sync physics. That is a very very hard problem.
Okay I got the movement and camera fixed!
I am having an issue tho. It appears that gRPC streams can't handle the amount of update messages. Which means I need an alternative, is there a different real time solution I can use? plain sockets?
But also you'll run into issues if you are trying to sync physics. That is a very very hard problem.
Which physics exactly?
btw a very big thank you for answering so many questions. Really really appreciate it!
since its passed midnight for me I will head to bad, but I hope you can help me out tomorrow!
You can use sockets but that's literally creating an entire networking stack from scratch.
PhysX in Unity is non-deterministic. Due to floating point errors, the same collision bounce when calculated on different machines could end up in slightly different positions. Those differences will eventually add up to desync the network state.
It will need to be server authoritative but that introduces lag that you'll have to deal with somehow.
You can use sockets but that's literally creating an entire networking stack from scratch.
Yea ik, part of the school project is to use gRPC which we do for stats, server lists, authentication, communication between the actual gameservers and our backend and so on.
There is not really a free and open source solution that offers self hosted dedicated servers