I want the player to rotate when standing on an object that rotates.
Answer by SohailBukhari
Apr 19 at 11:33 AM
You can simply assign Rotation of one object to other as:
Make Two gameObjects.
Copy the eulerAngles Of one gameObject and save into local variable.
Rotate your Object x and z axis as it is and change Y which you save into your local variable as in the script.
public GameObject ObjA;
public GameObject ObjB;
private void Start()
var yRotation = ObjB.transform.eulerAngles.y;
ObjA.transform.Rotate(ObjA.transform.eulerAngles.x, yRotation, ObjA.transform.eulerAngles.z);
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
7 People are following this question.
How can I modify this rotation code to change how far the object rotates?
CharacterController.Move Not Corresponding to gameobject.transform.rotation
How can I rotate my gameobject around z-axis correctly?
Moving player to generated position
How to keep a Gameobject in the same position after a transform.Rotate?