I am new to Unity. Now I am working with FPS camera. While pressing a key down arrow I want my camera to go down and again it come back to normal position. I am not getting any idea how to do it. Anyone, please help.


With "go down" do you mean "tilt down" (as in "you lower your head") or "move down" (as in "you go down on your knees")?

Anyway, both are done by manipulating the Transform-component of your camera.

Camera.main.transform.Rotate(vector3); rotates the currently active camera and setting Camera.main.transform.position = vector3; moves the camera to a different position. When you already have a script in your scene which controls the camera, you need to make sure that the scripts don't interfere with each other. We can not see your scene setup, so we can not help you with that.

To find out if a user is currently holding the down key, use if (Input.GetKey("down")) {

  • \$\begingroup\$ thanks for your answer. but i want a smooth flow of camera. the camera have to tilt in y axis smoothly \$\endgroup\$ – Manoj Balaji M Nov 26 '15 at 10:18
  • 1
    \$\begingroup\$ @ManojBalajiM That's why it's important that you are specific in your questions. Please create a new question where you post your current camera control code and explain exactly how it behaves and exactly how you would like it to behave instead. \$\endgroup\$ – Philipp Nov 26 '15 at 10:25
  • \$\begingroup\$ I Placed the camera in the player. the camera moves and jump with the player. if the player knees down the camera is not going down. \$\endgroup\$ – Manoj Balaji M Nov 26 '15 at 10:47
  • \$\begingroup\$ @ManojBalajiM As I wrote: Change the y-component of the camera position to control its height. \$\endgroup\$ – Philipp Nov 26 '15 at 12:21
  • \$\begingroup\$ but the speed is very high. I want to tilt it slowly \$\endgroup\$ – Manoj Balaji M Nov 27 '15 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.