c# – Unity camera lag when try to smooth

I’m having an issue with the camera in Unity when I try to make it smooth. Here’s the camera code

private void LateUpdate()
{
    transform.position = Vector3.Lerp(transform.position, target.position + offset, smoothTime * Time.deltaTime);

    transform.eulerAngles = new(0, 0, (float)(Mathf.Sin(Time.time * rotationSpeed) * rotationAngle));
}

And here’s the player movement code

private void FixedUpdate()
{
    inputX = joystickWalk.Horizontal;
    inputY = joystickWalk.Vertical;

    var angle = Mathf.Atan2(joystickLook.Vertical, joystickLook.Horizontal) * Mathf.Rad2Deg;
    if (angle != 0)
    {
        body.rotation = angle;
    }
    else
    {
        var walkJoystickAngle = Mathf.Atan2(joystickWalk.Vertical, joystickWalk.Horizontal) * Mathf.Rad2Deg;
        if (walkJoystickAngle != 0)
            body.rotation = walkJoystickAngle;
    }

    var direction = new Vector2(inputX, inputY) * speed;
    body.velocity = direction;
}

Interpolation is enabled on the Rigidbody component. The higher the FPS, the less lag I have.

Read more here: Source link