- Home /
Question by
marybolton1 · Jul 07, 2017 at 07:52 PM ·
camerarotationperspectivefirst person
First Person Camera Rotation Help
I'm trying to make the camera rotate with key clicks from a first person perspective. I'd like to tie the camera to the direction the game object is moving so that the player is always looking forward, but can still turn.
Here is what I have:
void Update () {
if (Input.GetKeyDown ("left")) {
Camera.main.transform.Rotate (Vector3.left, speed * Time.deltaTime);
}
if (Input.GetKeyDown ("right")) {
Camera.main.transform.Rotate (Vector3.right, speed * Time.deltaTime);
}
}
And I can't figure out why this doesn't work.
Comment
What happens? If you describe it might be better to help you
Answer by baboca · Dec 17, 2017 at 07:49 PM
Try parenting the camera to the gameobject, that way it will folow the object,s movements and it will be able to turn on its own(it will turn inside the parent object's local space).
Your answer
![](https://koobas.hobune.stream/wayback/20220612125648im_/https://answers.unity.com/themes/thub/images/avi.jpg)