17-09-2020, 07:47 AM
(This post was last modified: 17-09-2020, 07:48 AM by josemendez.)
(17-09-2020, 12:40 AM)dasbin Wrote: I was using rigidbody.position to do this.
But I guess this waits for the next physics update or something.
Just setting transform.position fixed it.
According to Unity you are not supposed to move rigidbodies this way, but I can't think of what else to do if I want it to move immediately.
rigidbody.position does wait for the next physics update, according to the documentation:
https://docs.unity3d.com/ScriptReference...ition.html
Quote:If you change the position of a Rigibody using Rigidbody.position, the transform will be updated after the next physics simulation step.
So rigidbody.position and transform.position are not functionally equivalent.
There's nothing wrong with setting the position using transform.position, as long as that's what you're after. I guess the warning is aimed at people that expect to be able to physically interact with rigidbodies by setting their transform instead of applying forces/impulses/accelerations.