so i have this script which i want to rotate around and zoom in and out of my player (Tornado).
my distance determins how far away the camera is from the tornado so i want when i scroll my mouse the distance will change making me get closer and further from the tornado. here is my script (void update) is where im having trouble with changing distance
private const float Y_ANGLE_MIN = 0.0f;
private const float Y_ANGLE_MAX = 50.0f;
public Transform lookAt;
public Transform camTransform;
private Camera cam;
public float distance = 10.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensitivityX = 4.0f;
private float sensitivityY = 1.0f;
private void Start() {
camTransform = transform;
cam = Camera.main;
}
private void Update()
{
currentX += Input.GetAxis ("Mouse X");
currentY += Input.GetAxis ("Mouse Y");
currentY = Mathf.Clamp (currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
distance += Input.GetAxis ("Mouse ScrollWheel");
distance = Mathf.Clamp (distance, 0.0, 10.0);
}
private void LateUpdate()
{
Vector3 dir = new Vector3(0,0,-distance);
Quaternion rotation = Quaternion.Euler(currentY,currentX,0);
camTransform.position = lookAt.position + rotation * dir;
camTransform.LookAt(lookAt.position);
}
}