Hello! I’ve been working on a little headbob script that also accounts for sprinting. The script works, but visually, it looks a little off. I believe this is simply because all of the different headbob states aren’t transition between each other smoothly, rather cutting in and out each other. Is there any way I can ease my camera into the new Vector 3? Thank you.

The Script:

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Headbob : MonoBehaviour {
public float rotFactor;
public float bobFactor;
public float speed;
public float sprintRotFactor;
public float sprintBobFactor;
public float sprintSpeed;
public float joystickIntensity;
public GameObject bobAnchor;
public bool changeDir;
private float bobAnchorZ;
public bool sprinting;
public bool moving;
public bool zoom;
void Start () {
bobAnchorZ = -(rotFactor / 2);
bobAnchor.transform.eulerAngles = new Vector3(0, 0, bobAnchorZ);
sprinting = false;
moving = false;
}
// Update is called once per frame
void Update () {
var euler = transform.localEulerAngles;
var camPos = transform.localPosition;
if (Input.GetButton("Sprint") || Input.GetAxis("Sprint") != 0)
{
sprinting = true;
}
if (!Input.GetButton("Sprint") && Input.GetAxis("Sprint") == 0)
{
sprinting = false;
}
if (Input.GetButton("Zoom") || Input.GetAxis("Zoom") != 0)
{
zoom = true;
}
if (!Input.GetButton("Zoom") && Input.GetAxis("Zoom") == 0)
{
zoom = false;
}
if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
{
moving = true;
}
if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
{
moving = false;
}
joystickIntensity = ((Mathf.Clamp01(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).magnitude)));
var angle = (Mathf.Cos(Mathf.PingPong(Time.time * speed, Mathf.PI))) * rotFactor * joystickIntensity;
var pos = (Mathf.Cos(Mathf.PingPong(Time.time * speed * 2, Mathf.PI))) * bobFactor * joystickIntensity;
var sprintAngle = (Mathf.Cos(Mathf.PingPong(Time.time * sprintSpeed, Mathf.PI))) * sprintRotFactor;
var sprintPos = (Mathf.Cos(Mathf.PingPong(Time.time * sprintSpeed * 2, Mathf.PI))) * sprintBobFactor;
if (moving)
if(sprinting == false)
{
transform.localEulerAngles = new Vector3(0, 0, angle);
transform.localPosition = new Vector3(0, pos, 0);
}
if (moving)
if (sprinting)
if (zoom)
{
transform.localEulerAngles = new Vector3(0, 0, angle);
transform.localPosition = new Vector3(0, pos, 0);
}
if (moving)
if (sprinting)
if(zoom == false)
{
transform.localEulerAngles = new Vector3(0, 0, sprintAngle);
transform.localPosition = new Vector3(0, sprintPos, 0);
}
if(moving == false)
{
transform.localEulerAngles = new Vector3(0, 0, 0);
transform.localPosition = new Vector3(0, 0, 0);
}
}
}
```