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.


descriptionNeeding some help one gun movement EmptyNeeding some help one gun movement

more_horiz
Hello my name is bosstvgames and im here to get some help on the gunmovement. Im starting my own fps game so i need the gun to follow my cursor/crosshair. So I made a java script with this inside it and when i add it onto the first person character and add the gun to it the gun will disappear I dont know if im doing anything wrong please tell me if i am will anyone help me? thanks -bosstvgames

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

}

descriptionNeeding some help one gun movement EmptyRe: Needing some help one gun movement

more_horiz
This should be attached to your weapon not the Character Controller
Attach it to your weapon and drag and drop its self into the "GUN" variable
That should do the trick.

descriptionNeeding some help one gun movement EmptyRe: Needing some help one gun movement

more_horiz
I need help in making creatures and the script that can make the FPS to change weapons by scrolling the mouse.

descriptionNeeding some help one gun movement EmptyRe: Needing some help one gun movement

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