- Home /
Player rotation = Camera Rotation
Im making thirdperson player, and when I aim the player needs to rotate along with the camera rotation.
```
public Aim aimScript;
void Update()
{
if (aimScript.Aiming)
{
transform.rotation.y = Camera.main.transform.rotation.y;
}
}
```
Error Message: Cannot modify the return value of 'Transform.rotation' because it is not a variable
Thanks in advance
Comment
You error is solved like this:
if (aimScript.Ai$$anonymous$$g)
{
transform.eulerAngles = new Vector3(Transform.eulerAngles.x,Camera.main.transform.eulerAngles.y, Transform.eulerAngles.z);
}
Your answer
Follow this Question
Related Questions
Keep camera at certain distance from character when rotating 3 Answers
How do i lock the position of the camera above the player relative to the origin point? 0 Answers
nullifying targetObject after a Smooth LookAt Transition 2 Answers
Rotating Camera around player object 0 Answers
Calculate Quaternion upward ? to keep the rotation of camera 2 Answers