Question by
okaybj · Sep 18, 2020 at 07:25 PM ·
first person controller
smoothly transition to new clamp
working on an fps controller and I am clamping the pitch of the camera more when the player is sliding so that they cant look down as much. problem is the clamp snaps to the new clamp when the player starts sliding. I want it to smoothly transition to the new clamp instead. Any help? Here is my code:
if (player.move_forward == true)
{
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
if (player.is_sliding == true)
{
pitch = Mathf.Clamp(pitch, slidingPitchMinMax.x, slidingPitchMinMax.y);
yaw = Mathf.Clamp(yaw, yawMinMax.x, yawMinMax.y);
}
else
{
pitch = Mathf.Clamp(pitch, pitchMinMax.x, pitchMinMax.y);
yaw = Mathf.Clamp(yaw, yawMinMax.x, yawMinMax.y);
}
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
Comment