#Smooth Camera Movements

1 messages · Page 1 of 1 (latest)

round cape
#

I currently have this script for my camera movement to zoom in and out. My zoom is achieved by moving my camera closer or further away from the pivot it is attached to on the z-axis. This code results in jittery movements that are not very pleasing to look at. I have tried using SmoothDamp and tranform.Translate but neither achieved a smooth result either.

float zoom = zoomAction.ReadValue<float>();
if (zoom != 0)
{
    offset -= zoom *  zoomSpeed;
    offset = Mathf.Clamp(offset, 2, 100);

    float positionDelta = offset - currentPosition;
    
    
    
    // camera.transform.Translate(new Vector3(0, 0, -positionDelta));
    currentPosition += positionDelta;

    // float velocity = 0f;

    mainCamera.transform.localPosition = new Vector3(0f, 0f, -currentPosition);
    // camera.transform.localPosition = new Vector3(0, 0,
    //     Mathf.SmoothDamp(camera.transform.localPosition.z, currentPosition, ref velocity, 0.2f));

}
maiden brook