Simple eulerAngles in Update() not updating

I feel like I’m so close but I don’t understand why this isn’t working.

function Update () 
{
 transform.eulerAngles = 
    Vector3(0,0,Vector3.Angle(transform.position, Vector3.zero)-90);
}

Essentially I’m trying to make an object always orienting downwards towards the origin point of a scene in the xy axis. However, while the code seems to work on startup and set the angle to the correct angle, the object’s angle does not continue to update afterwards.

What am I missing here?

You’re constantly setting transform.eulerAngles to the same value.
So each time Update() runs, the value is the same.

You need to look at the linear interpolation functions offered by Unity.

Take a look at Mathf.Lerp, Vector3.Lerp etc.

Here is a small script I use to rotate a spacestation. I rotates wherever it is around it’s up-axis

public class StationRotation : MonoBehaviour {
 
 public float speed = 10.0f;
 
 void Update () {
 transform.Rotate(Vector3.up * Time.deltaTime * speed);
 }
}

Maybe that helps.

The keyword “new”?

transform.eulerAngles = new Vector3();

Did you look at this sample? Unity - Scripting API: Transform.eulerAngles