How do i make my weapon sway?

Just wondering how i would make my glock sway in the dirrection of the mouse moveing? do i have to animate 4 different ways and it blends them together or is there a simpler way?

Yah Just Copy and Paste This Code to The Gun Then Under the GUN Click and Drag Your Gun To It

Code:

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);
	

     }

Here, use this code and under GUN drag your gun to it

Code:

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);

}