#Jittery first person view

1 messages · Page 1 of 1 (latest)

fallen geyser
#

I have a fairly simple first person movement and camera script, the camera is attached to the player object.
Moving without rotating the camera works fine, but if I move and look around at the same time the objects in view appear to jitter.

I tried enabling interpolation on the player rigidbody, briefly disabled resetting moveDir after the force has been applied (see code below), tried defining the rotation angles differently using transform.Rotate instead, but none of these worked. The coroutine timer at the bottom of the script doesn't do anything, but I have tried disabling it, to no effect.
Other scripts don't have any functions that would affect the player rb, Time.timeScale is default (1).

See script attached.

devout scrollBOT
frail kiln
#

@fallen geyser Try moving this part to FixedUpdate

fallen geyser
#

I should've mentioned I've already tried that too, but it makes mouse movement itself much more incosistent since it's only updated once every physics frame

frail kiln
#

Hmm what if you took only the parts that set the camera rotation? (The two lines of code). That way, the values are updated faster.

fallen geyser
#

That seems to be a bit better, the camera rotation's framerate is still a bit lower which is not ideal, but it's not as jarring as when I moved it all to fixedUpdate. I think I'll make do with this for now, thanks!

dusty spoke
#

I use the InputSystem, but maybe you can do something with this?

    public void OnMouseMove()
    {
        mouseDirection = InputMgr.Instance.GetMouseMovement();
        xRotation -= (mouseDirection.y * Time.deltaTime) * 10f;
        xRotation = Mathf.Clamp(xRotation, -90, 90);
        _camera.transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
        transform.Rotate(Vector3.up * (mouseDirection.x * Time.deltaTime) * 10f);
    }
fallen geyser
#

Adding Time.deltaTime doesn't seem to do much since it's all base on mouse movement, I assume it would be needed for controller support. Appreciate the suggestion though