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) » Needing some help one gun movement

Needing some help one gun movement

Go down  Message [Page 1 of 1]

1 Needing some help one gun movement on Sat Mar 08, 2014 11:03 pm


Member [Lv. 0]
Member [Lv. 0]
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);


View user profile

2 Re: Needing some help one gun movement on Tue Mar 11, 2014 3:33 am


Member [Lv. 3]
Member [Lv. 3]
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.

View user profile

3 Re: Needing some help one gun movement on Sun Jun 15, 2014 5:19 am

Ninjaboy follower

Member [Lv. 3]
Member [Lv. 3]
I need help in making creatures and the script that can make the FPS to change weapons by scrolling the mouse.

View user profile

Sponsored content

Back to top  Message [Page 1 of 1]

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