#Jittery Client with CSP v2

67 messages · Page 1 of 1 (latest)

onyx grail
#

Known issue on v2, it's still in experimental. You can try v1 on 374, it got some timing updates which may help.

#

Jitter on v1 on latest shouldn't be an issue unless your CSP is off

grizzled elm
somber sierra
# grizzled elm I'm having the same problem on CSP v1. The camera looks around with the mouse, a...

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

grizzled elm
somber sierra
# grizzled elm You put the camera rotation logic in Update?

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

grizzled elm
#

What do you mean "don't sync the camera themselves"

somber sierra
#

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

grizzled elm
#

I put it in my Update function

somber sierra
#

that's just my thought, I think if it's running over the network, it's going to be jittery

#

ok gotcha

grizzled elm
#

Do I need an IsOwner check?

#

so only owner doesn't sync over the tick?

somber sierra
#

if that is in move, then you are setting the camera as part of CSP

grizzled elm
somber sierra
#

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?

grizzled elm
#

My camera is parented inside of the player, each player has a camera

somber sierra
#

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

grizzled elm
#

oooooh

#

makes sense!

somber sierra
#

actually I think reconciliation only runs on the owner client, so you might just be able to remove it completely

grizzled elm
#

Holy crap, the camera and player look are finally smooth!

somber sierra
#

woohoo!!

grizzled elm
#

but on the client it's jerky

#

lemme get a video

somber sierra
#

ok

#

also I think you're applying deltaTime twice to gravity

#

because you do

gravity = gravityScale * deltaTime;
moveVector.y = gravity;

// ...
controller.Move(moveVector * deltaTime);
grizzled elm
#

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

somber sierra
#

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:

  1. MoveData with correct data,
  2. MoveData with defaults
  3. 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? 😛

grizzled elm
#

Is that because my inputs aren't normalized?

somber sierra
somber sierra
grizzled elm
somber sierra
#

I don't have mine on for my game. I'm not really sure how CSP works as client auth

grizzled elm
#

You're making an FPS game too?

somber sierra
#

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

grizzled elm
somber sierra
# grizzled elm 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

grizzled elm
crystal geyserBOT
#

ttay24 received thanks.

grizzled elm
#

😭

#

i'm just going to figure out mine

grizzled elm
#

🙂

somber sierra
grizzled elm
#

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?