On that scene I have a root gameobject with capsule collider and kinematic rigidbody attached.
AutoSyncTransforms is off, I call Physics.SyncTransforms() manually in Update after I change a rigidbody position
AutoSimulation is off, I never call Physics.Simulate() manually (I only use physics scene for raycast queries).
I then update rigidbody.position in every update to some random value. Both in inspector and in physics debugger I can see rigid body world position changes appropriately, however those changes are never propagated back to gameobject.transform.position, and on the scene view it seems like the capsule is standing still.
The question is, how do I update transform’s position, when attached rigidbody’s position changes? The obvious way is to set them both:
But it feels like this code negates any performance benefits of using rigidbody in the first place. Is this the proper way to handle this situation?
Or should I just ignore incorrect transform position? I don’t use it for anything other than viewing colliders in scene view
If you’re never running the simulation then do what you’re doing above.
Write-back of Rigidbody(2D) → Transform is how it’s supposed to happen and is the final thing, prior to physics callbacks to happen. No simulation then of course it’s never going to happen.
You should never have to call SyncTransform ever. That’s for read-back i.e. forcing user-changed Transforms back to the Rigidbody poses. You don’t seem interested in that but avoid it, it can get expensive. You can always turn-on AutoSyncTransform which does this for you if you ever read the simulation state such as queries etc but know this will be called whenever you do a read so if you’re doing move position, ray-cast, move position ray-cast then it’s terrible to do.
Changing the Transform only changes the Transform so no performance loss. Changing the Body pose only changes the body pose so no performance loss.