I’m trying to get this script to work, but it says “NullReferenceException: Object reference not set to the instance of an object” On line 16. Please help, and thanks ahead of time!
public var MoveAmount : float = 1;
public var MoveSpeed : float = 2;
public var GUN: GameObject;
public var MoveOnX : float;
public var MoveOnY : float;
public var DefaultPos : Vector3;
public var NewGunPos : Vector3;
function Start(){
DefaultPos = transform.localposition;
}
function Update () {
MoveOnX = Input.GetAxis("Mouse X") * Time.deltaTime * MoveAmount;
MoveOnY = Input.GetAxis("Mouse Y") * Time.deltaTime * MoveAmount;
NewGunPos = new Vector3 (DefaultPos.x+MoveOnX, DefaultPos.y+MoveOnY, DefaultPos.z);
GUN.transform.localPosition = Vector3.Lerp(GUN.transform.localPosition, NewGunPos, MoveSpeed*Time.deltaTime);
}