Player and gun rotation problems in FPS shooter
Hi, I'm creating a first person shooter and I am having trouble getting the gun and the player to rotate how I want them to rotate.
First of all, the player looks like this:
When I move my mouse, I want the gun and camera to rotate both horizontally vertically and the player itself to only move horizontally (since vertical rotations will cause it to look weird). Since the player object is a parent of both the gun and camera, I can't make this possible.
I tried using this:
transform.rotation = Quaternion.Euler(0, xRot, 0);
camera.transform.rotation = Quaternion.Euler (yRot, 0, 0);
However, whenever I do that the player rotates horizontally without the camera and gun following.
How can I fix this problem?
Thanks,
~~Higgsboson728
Edit: I tried creating an empty gameobject and making it a parent of the gun, but I still can't get it to work..
Edit 2: Ok, I did some research and I made two separate scripts to move each part of the player, but one cancels out the other and at the end the result is the same
Your answer
Follow this Question
Related Questions
How to lock X rotation on 3D object? 0 Answers
transform.parent.localRotation not working (Object reference not set to an instane of an object) 0 Answers
3D Top Down shooter mouse follow inaccurate at some angles 0 Answers
Rotate Rigidbody towards target rotation using AddTorque() 0 Answers
How do you maintain gravity using transform.forward and transform.right? 0 Answers