Movement Stutter with States/Commands

Forcas
Forcas
edited November 2018 in Photon Bolt
Hello,
I have a local camera which follow the player.
camera is controlled locally to follow the player (on each client separately) on LateUpdate
however the camera is stuttering as the player movement is not 100% smooth as every time execute command happens -> reset state is setting the transform different (after server accepted) to the previous position
i followed the tutorial on bolt documentation (advanced one)
what am i doing wrong ?

Controller

Movement

Updated : Video






Comments

  • Video isn't working. If your camera isn't smooth and just goes to an absolute offset of the player it will jitter. See the camera example from the tutorial.
  • Forcas
    Forcas
    edited November 2018
    Updated : Video
    The camera is smoothing. and its targeting the player GameObject

    However the ExecuteCommand(Command command, bool resetState)
    since the resetState always comes true on the client, the pmScript.SetState(cmd.Result.Position,cmd.Result.Rotation); is setting the position forcefully to the location OKed by the server so there is a micro teleportation of the player to the back since on client side it already passed that position.
    i went through the advanced tutorial again i didnt find anything to ignore reset value within a threshold

  • I have done the following as work around but i am not sure if this is the correct way
    .
    public void SetState(Vector3 position, Quaternion rotation)
        {
            // assign new state
            _state.position = position;
            _state.rotation = rotation;
            // assign local position
            if ((transform.localPosition - _state.position).magnitude > 1)
                transform.localPosition = _state.position;
            if (Quaternion.Angle(model.transform.rotation, _state.rotation) > 5)
                model.transform.rotation = _state.rotation;
        }