Transform a gameobject y rotation to another gameobject y rotation

I want the player to rotate when standing on an object that rotates.

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);
    }