# When I press play in my scene, the camera turns in the opposite direction?

In my scene, I have my character facing a certain direction, with a camera attached. Now, when I press play, for some reason, the character immediately faces the other way. I've tried turning the model and camera to face the opposite way of that, to make up for it, but it still faces that same direction.

I've had a look at the script for the camera, but I'm not sure what could be causing this to happen. There's no target assigned that should cause that reaction, as the camera is a child of the player.

Below is a copy of my script:

public class FirstPersonCamera : MonoBehaviour
{
Vector2 mouseLook;
Vector2 smoothV;
public float sensitivity = 5.0f;
public float smoothing = 2.0f;

GameObject character;

void Start()
{
character = transform.parent.gameObject;

Debug.Log("Camera is operating");
}

void Update()
{
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));

md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
mouseLook += smoothV;

transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, character.transform.up);

Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = true;

if (Input.GetKeyDown("escape"))
{
Cursor.lockState = CursorLockMode.Locked;
}

}

}


Does anyone see what could be causing this issue? I've using Unity version 2019.2

I'm also including screenshots of the player's position, as well as the camera's.

Player:

Camera:

There's something in the script that is causing the character to turn around, as I placed the script on another model and it had the same effect P:

• You are trying to rotate the camera and player both in a different direction and maybe that is causing the problem, I suggest you check on "transform.localRotation" line, try commenting it. – Kartik Shah Nov 10 '19 at 9:28
• @KartikShah I just tried it, however it had the same affect as when I tried commenting out the line below it too. The odd thing is, the camera is physically placed in the same direction as the player, so i'm really stumped as to why this is happening, when it wasn't an issue previously. – CraftyMaelyss Nov 10 '19 at 10:59
• What position is the camera at within the parent character's coordinate space? – DMGregory Nov 10 '19 at 14:00
• @DMGregory The camera is placed in front of the model's eyes, to replicate first person. I'm updating the question with screenshots to help show the details. – CraftyMaelyss Nov 12 '19 at 1:18
• Be sure to include numbers! – DMGregory Nov 12 '19 at 1:20

 transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);