FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

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

descriptionRe: 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.

descriptionRe: gun movement

more_horiz
where is that?
Permissions in this forum:
You cannot reply to topics in this forum