Hi,
In my Game I am working on you have a PlayerUpperBody and a PlayerBottomBody. I want the PlayerUpperBody’s rotation to be set at the PlayerBottomBody’s rotation.
I tried:
PlayerUpperBody.rotation.y = transform.rotation.y;
But then it says I can’t modify a value type return value of ’ ‘UnityEngine.Transform.rotation’
Anyone knows how to solve this?
If you wish to change rotation you need to set whole transform.rotation to the new value.
So in your case it could be something like:
Quaternion newRotation = PlayerUpperBody.rotation;
newRotation.y = transform.rotation.y;
PlayerUpperBody.rotation = newRotation;
I need to warn you Quaternion is not Vector3 and it works different. So it would be more correct to work with transform.eulerAngles instead.