Hello,
I am doing a side scroller game for my coursework and I have to rotate the camera on the Y axis by 180 degrees.
Currently I have my character moving right with the camera and when I move left I am rotating the character. Because my camera is a child object of my character it rotates as well.
I would like it to stay at the original position just like when I am moving right.
Here is the code I am using to move left/right and rotation of my character.
moveDirection.x += Input.GetAxis("Horizontal") ;
if(moveDirection.x>speed)
{
moveDirection.x = speed;
transform.eulerAngles = Vector3(0, 90, 0);
}
if(moveDirection.x<-speed)
{
moveDirection.x = -speed;
transform.eulerAngles = Vector3(0, -90, 0);
transform.gameObject.camera = Vector3(0, 90, 0);
//This should be the code to rotate the camera to the original position.
}
When I run the following code it shows me the following error
Assets/Scripts/PlatformWalker.js(52,43): BCE0053: Property 'UnityEngine.GameObject.camera' is read only.
I understand I am doing something wrong but because I am just starting in programming I do not know how to fix this error.
If someone could help me it I would much appreciate it.
Regards,
Lukasz K.


