- Home /
Question by
D3m0nE · Jul 11, 2013 at 09:50 PM ·
gameobjecttop-downsway
Airplane Sway In Top-Down Game
Hello, i'm Trying to create Top-Down Game
i'm trying to make my Airplane Sway to left and right when mouse moving
here is my Sway Script :
public var MoveAmount : float = 1;
public var MoveSpeed : float = 2;
public var AirPlane: 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);
AirPlane.transform.localPosition = Vector3.Lerp(AirPlane.transform.localPosition, NewGunPos, MoveSpeed*Time.deltaTime);
}
for somehow this script make my airplane Jumping its like swaying Up not to the left or right.
how i make it sway in Z axis ?
Comment