Rotation of object on edge of sphere

Trying to set the rotation of a series of objects on a sphere so they are all facing outwards.

After instantiating the object and placing it under a holder object as it’s parent, I’m attempting to rotate it so it’s rotation is 90, 0, 0 (according to the editor’s transform).

All attempts to set them at (90, 0, 0) through code have failed.

Have tried using Quaternions in .rotation, .eulerAngles, .localEulerAngles, .Rotate and they all end up having random rotations when I look at them in the editor or Debug.Log them.

Any ideas how I can set them to the equivalent of 90, 0, 0 in the editor?


You have two options to set a specific eulerangles combination for each space.

// Sets the world space rotation
transform.eulerAngles = new Vector3(90,0,0);
transform.rotation = Quaternion.Euler(90,0,0);

// Sets the local space rotation (as seen in the inspector)
transform.localEulerAngles = new Vector3(90,0,0);
transform.localRotation = Quaternion.Euler(90,0,0);

Keep in mind that setting the local rotation need to be done after you parented your object.