This script do that when I move the mouse X the gun rotates but i have an error:
Assets/GunMoveMentewfweaf.js(18,33): BCE0024: The type 'UnityEngine.Quaternion' does not have a visible constructor that matches the argument list '(float, float, float)'.
The Script:
public var RotateAmount : float = 1;
public var RotateSpeed : float = 2;
public var GUN: GameObject;
public var RotateOnX : float;
public var RotateOnY : float;
public var DefaultRot : Quaternion;
public var NewGunRot : Quaternion;
function Start()
{
DefaultRot = transform.localRotation;
}
function Update ()
{
RotateOnX = Input.GetAxis( "Mouse X" ) *Time.deltaTime * RotateAmount;
RotateOnY = Input.GetAxis( "Mouse Y" ) *Time.deltaTime * RotateAmount;
NewGunRot = new Quaternion ( DefaultRot.x+ RotateOnX, DefaultRot.y+ RotateOnY, DefaultRot.z);
GUN.transform.localRotation = Quaternion.Lerp(GUN.transform.localRotation, NewGunRot , RotateSpeed * Time.deltaTime);
}