Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » gun movement

gun movement

View previous topic View next topic Go down  Message [Page 1 of 1]

1 gun movement on Wed Feb 05, 2014 8:14 am

ikke14063


Member [Lv. 0]
Member [Lv. 0]
hey,

I have a problem. My gun movement script doesnt work do you know what is wrong?

My gun movement script:
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);

}


Please help me!

View user profile

2 Re: gun movement on Sun Feb 16, 2014 4:51 pm

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

}

It doesn't really look like you got anything wrong in the script, maybe it is just how you set it up with the gun asset. I re- wrote the script, with proper spacing.

View user profile http://www.youtube.com/user/misterninjaboy

3 Re: gun movement on Mon Jul 28, 2014 3:38 pm

songhai


Member [Lv. 1]
Member [Lv. 1]
where is that?

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum