- Home /
Rotate child of FPS when camera moves on Y-axis
I have a First person controller with a gun as a child. When the FPS looks left or right, the gun moves with it so the gun is pointing in the direction the FPS is looking.
Now, when the FPS looks up or down , I want the gun to rotate forward or back (to simulate the FPS looking down the sights of the gun). What FPS or Camera event can I tap into to achieve this?
Answer by KdRWaylander · Aug 07, 2015 at 09:27 AM
Hi,
Not sure to understand what you want here but let me try anyway ^^
Check for the vectical axis input (http://docs.unity3d.com/ScriptReference/Input.GetAxis.html) and then modify localEulerAngle of your gun with something like:
float rotationValue = Input.GetAxis("Vertical") * speed;
Answer by sisse008 · Jun 28, 2017 at 01:07 PM
not sure what you mean but if you attach the child object to the FirstPersonCharacter and not to the FPSController, the child object will move on the y-axis too.
Your answer
Follow this Question
Related Questions
Child of main camera not following correctly 1 Answer
First Person Controller not working 1 Answer
First person camera restriction. 1 Answer
Move character in direction its facing 1 Answer
Camera rotate - point and click game 1 Answer