UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptiongun movement Emptygun movement

more_horiz
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!

descriptiongun movement EmptyRe: gun movement

more_horiz
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.

descriptiongun movement EmptyRe: gun movement

more_horiz
where is that?

descriptiongun movement EmptyRe: gun movement

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply