- Home /
Unity3d FPS Gun rotating on camera issue
Im having a problem with the guns in my game, as they rotate on the X axis, they tend to rotate in an orbit not following the camera. I put a video on youtube to show it
http://www.youtube.com/watch?v=X9LHxsjjEl0
this has been driving me insane........
Thats actually kind of cool looking the way it is... Just hook some arms up to the guns so it looks like the guy is reaching up to shoot as he leans back a little, rather than the usual way of looking as if the characters arms are bolted into one position at his side as they lean back far enough to snap his spine. EDIT : also, seeing part of your script might help someone help you get it to work how you want it to.
The problem looks like messed up(or misplaced) pivot points. If you modeled the guns in a 3D app, make sure the model is as close to 0 0 and 0 translation as possible.
actually parent the guns in the camera. EDIT: and also you need to adjust the views of the camera. Like the viewing area. And the viewing length.
Answer by Stephen 1 · Dec 12, 2011 at 02:51 AM
there is no script...thats the kicker, the only script is the mousemove script so that i can move the camera up and down...,there is no script atm...thats the confusing part, all i have is the mouselook on the camera for the y axis and the guns are children of the camera...
...And you wonder how it's done? It's the mouselook AND weapons being the children. Once a GameObject is attached to another GameObject, it's rotation and position is relative to PARENT. So if you move the camera the weapons will move to stay on their relative position too. Try detaching the weapons and you'll see they stop moving.
Answer by drkdagron.du · Dec 12, 2011 at 05:54 PM
But if I am to disconnect the weapons from the camera, then the weapons lose there movement up and down...how should I go about fixing this? Should I change the pivot on the gun in Maya to the difference in transforms from where the camera is to the hand, so that the pivot is zeroed with the camera so it'll rotate with the camera 1 for 1?
Your answer
Follow this Question
Related Questions
How does this first person camera script work? 0 Answers
First Person Shooter Help With Cam 1 Answer
Setting camera pitch - Never works? 0 Answers
How do I properly rotate an FPS camera with a joystick? 1 Answer
Storing camera angles for a FPS -1 Answers