Why does this have to be in an update method?

All I wanted to do was move the centre of mass of a rigid body, but it wouldn’t work unless I put it in an update, like this.

using System.Collections;

public class CoM : MonoBehaviour {


void Update() {
        rigidbody.centerOfMass = new Vector3(0, 0, -2);
    }
}

I just don’t see why you can’t put it in a custom method like “void MoveCenter()”.

Btw I’m learning Unity3d and C# at the same time.

instead of placing it in Update(), place it in Start()

void Start() {
   rigidbody.centerOfMass = new Vector3(0, 0, -2);
}

Update() gets called every frame, Start() only once in the beginning. If you would place it in MoveCenter() it would never get called.