I have a problem where a script that is just supposed lerp the gun object between a hip and zoomed firing position isn’t working at all.
using UnityEngine;
using System.Collections;
public class GunZoom : MonoBehaviour {
public Vector3 hipPos;
public Vector3 zoomPos;
void Update () {
if(Input.GetButton("Zoom")) {
transform.localPosition = Vector3.Lerp(transform.localPosition, zoomPos, Time.deltaTime);
}
else {
transform.localPosition = Vector3.Lerp(transform.localPosition, hipPos, Time.deltaTime);
}
}
}
The “Zoom” button is just the right mouse button. When I click it, nothing happens. The gun is a child of the camera, which is a child of the player object. Any ideas?