#Jittery Client with CSP v2
67 messages · Page 1 of 1 (latest)
I'm having the same problem on CSP v1. The camera looks around with the mouse, and I want to predict the camera, but if I put the camera look script in the TimeManager tick, looking around is limited to 30 fps, which is a terribly, jerky experience, so I put the camera look script in Unity's update. How do I predict the camera look while having it smooth at my monitors frame rate?
I wouldn't put the camera rotation logic in with CSP. I am currently using the camera to help determine where you move (meaning forward should be forward in the direction of where the camera is facing). I am currently sending the rotations of the camera that I need as part of my MoveData and that is working well. I would maybe try something like that? Pull in the camera's values (rotation, position, w/e you need) on BuildMoveData
You put the camera rotation logic in Update?
like this?
no it's in a completely different component. I added something like a transform member for the camera in my CharacterController
private Transform _cameraTransform
and then in my build data function, I set those in move data. So MoveData class has something like:
public Quaternion CameraForward;
and build data has:
moveData.CameraForward = _cameraTransform.Forward;
I wouldn't sync the cameras themselves, let the client own those, but have variables in the controller that follow those and sync those in the movedata/reconcile. I would try that out
and then you can sync the player rotations so that the weapon follows along
What do you mean "don't sync the camera themselves"
I wouldn't let the character controller actually set the camera. You mentioned putting camera movement in the CSP and that it was slow. I would try not putting it in CSP, rotate the camera elsewhere
I put it in my Update function
that's just my thought, I think if it's running over the network, it's going to be jittery
ok gotcha
if that is in move, then you are setting the camera as part of CSP
Then won't the movement be unsyncronized because the camera isn't at the right rotation?
what else is in your Move function? Do you have a physical camera object for each player? Or only one camera that follows the owner's character?
My camera is parented inside of the player, each player has a camera
yeah, so if you're reconciling the camera, that is fine for other clients, but it is not great for the owner of the object because then the server owns the rotation of your camera
so maybe try wrapping the camera.localEulerAngles = in reconcile
with a !base.IsOWner
like you do that the beginning of the move function
actually I think reconciliation only runs on the owner client, so you might just be able to remove it completely
Holy crap, the camera and player look are finally smooth!
woohoo!!
ok
also I think you're applying deltaTime twice to gravity
because you do
gravity = gravityScale * deltaTime;
moveVector.y = gravity;
// ...
controller.Move(moveVector * deltaTime);
So on the server, it moves fine, on the client, I press forward, and it moves forward for a second, and then it goes backwards/sideways
I'm only pressing the Forward key on the client
gotcha ok. So this is just a thought because this is what was happening to me, but throw some logs into the Move function and log move.vertical
So what was happening to me, is that in some cases, my client was running Move with default MoveData from the server. This was causing it to run with:
- MoveData with correct data,
- MoveData with defaults
- MoveData with correct data
etc...
and it gave this really weird laggy sensation, but when running it on a different machine, it worked fine. I ended up added a boolean to my move data, and I set it in BuildMoveData to true. Then in my Move function, I did something like:
if (!moveData.NotDefault)
return;
so that it wouldn't run when it received one of those default packages
that might not be what's happening to you, but might be worth investigating
also just thought about this, but you may want to normalize the input vectors that you get from MoveData because I'm pretty sure they just come straight from the server What happens if I as the client decide to sent you the my move forward speed is actually 4, and not 1? Do I get to go super fast? 😛
Yeah, I put a isOwner check around the entire Reconciliation function, and my client moved at super speed
Is that because my inputs aren't normalized?
yeah most likely, I would normalize in the BuildData and in the beginning of Move so that someone can’t cheat
like dis?
yeh
Client Authoritive checkbox in NetworkTransform is supposed to be on, right?
I would not, unless you're not concerned with cheating
I don't have mine on for my game. I'm not really sure how CSP works as client auth
You're making an FPS game too?
no I'm not 😛 I'm trying to make an asymmetrical game lol.
Have you checked out the FPS Land demo with Fishnet pro? Might be helpful for you
wiat, where the heck do I find this
http://firstgeargames.com/
You need to have GitHub or Patreon. You can do the $10 tier to get FishNet Pro and 2 example projects, and FPS and a Lobby+Worlds system. I basically built my lobby system using the example there. It was super helpful.
You can then downgrade to the $1/month tier after the initial $10 tier to continue to get FN Pro updates and any updates to the example projects
well worth it imo
oh, i have it already
may your soul rest in peice. thank you bro
ttay24 received thanks.
wai wai waittt i do not understand this
😭
i'm just going to figure out mine
i changed it back to Prediction V2 and now there is no more camera jittter
🙂
oh awesome! Congrats 😄 I haven't messed with V2 yet myself, so that is awesome to hear
With CSPv2, I'm having this error. my client doesn't sync the position correctly when it joins a new server. If I move a Client1 before Client2 joins, Client2 puts Client1's position at the starting position, instead of where Client1 actually is. @onyx grail is that a bug or being solved?