- Home /
 
Making a FPS, my gun floats sideways in front of me?
 var cameraObject : GameObject;
 @HideInInspector
 var targetXRotation : float;
 @HideInInspector
 var targetYRotation : float;
 @HideInInspector
 var targetXRotationV : float;
 @HideInInspector 
 var targetYRotationV : float;
 
 var rotateSpeed : float = 0.3;
 var holdSide : float = - 0.5;
 var holdHeight : float = 0.5;
 var holdLength : float = 0.5;
 
 
 function Update () {
     transform.position = cameraObject.transform.position + (Quaternion.Euler(targetXRotation, targetYRotation, 0) * Vector3(holdSide, holdHeight, holdLength));
     
     targetXRotation = Mathf.SmoothDamp( targetXRotation, cameraObject.GetComponent(MouseLook).xRotation, targetXRotationV, rotateSpeed);
     targetYRotation = Mathf.SmoothDamp( targetYRotation, cameraObject.GetComponent(MouseLook).yRotation, targetYRotationV, rotateSpeed);
 
     transform.rotation = Quaternion.Euler(targetXRotation, targetYRotation, 0);
 }
 
               Here's what it ends up looking like: 
I Have tried for hours to try and fix this, and I am also new to coding so talk to me like I know nothing. The script on the right is my script for my mouse aiming/looking in case that's also needed. Please help! Been stuck for a month and have re-scripted 3 times to try and fix this.
Rotating in the editor won't help; you need to rotate it in your modeling program or make it a child object and rotate it relative to its parent, then move the parent like it's the gun ins$$anonymous$$d of moving the gun itself.
Answer by InhailedYeti · Jan 13, 2013 at 08:18 AM
I solved it, I had to rotate the object in blender before importing.
Your answer
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do you add a fixed joint to a first person controller 1 Answer
My Enemy AI doesn't work(FPS). 1 Answer
Cant assign animation to script 1 Answer
Problems With Networking. 0 Answers