Is it a bad idea to have multiple scripts attached to a game object, each of which modifies a particular aspect of the object's position by calling rigidbody.MovePosition? Stated another way: are there undesirable performance implications to calling MovePosition more than once per FixedUpdate?
Also, is it important to avoid calling MovePosition if the x/y/z values are not being modified?
asked Jan 11 '10 at 04:20 PM
Well, the more times you call MovePosition the more CPU power it will take, so it is best to use it as few times as possible, store the desired position to move to in a variable which you change during FixedUpdate, and then in the end of your FixedUpdate call MovePosition once using the data from that variable, that will save you some CPU time.
For the same reasons it might be good to check if the position is being altered before you call MovePosition and call it only if it does change.
answered Jan 11 '10 at 04:57 PM