Unity Issue Tracker - RigidBody GameObject's position gets randomly reverted when transform.position in Update() is used
Closed
UUM-67811
RigidBody GameObject's position gets randomly reverted when transform.position in Update() is used
Unity: PhysX
Won't Fix
6.0.X
2023.2.X
2022.3.X
Explained here: https://blog.unity.com/engine-platform/expanding-the-robotics-toolbox-physics-changes-in-unity-20221 in the interpolation section. We no longer force sync all transforms each Update when there are interpolated bodies in the scene.
Reproduction steps:
1. Open the attached “PhysicsRepro.zip” project
2. Open the “SampleScene” scene
3. Enter the Play mode
4. Press the “Space” button and observe the Cube’s movement
Expected result: The Cube gets teleported with no glitching
Actual result: After a few button presses, the Cube starts glitching or stops moving, even though the Console shows the "Teleported cube!" log
Reproducible on: Windows 11
Not reproducible on: no other environment tested
Notes:
Sometimes it takes to press the “Space” button 5-10 times for the issue to appear
Changing the “Fixed Timestep” in Time settings from 0.02 to something like 0.005 makes the issue more apparent
Reproducible both in the Editor and the Player
A possible workaround is to set Rigidbody.position every time the position of a transform that has Rigidbody attached changes, this prevents the issue since the position is manually synced to the physics engine
The reporter also noted another workaround - manually calling Physics.SyncTransforms after changing transforms and calling it once every frame in LateUpdate. This workaround can be tested by enabling “== ENABLE THIS STOP THE ISSUE ==” GameObject, however, this workaround doesn’t work in all situations
This issue also causes NPC ragdolls to "explode" glitching out across the whole screen when they are switched from animated walking around to ragdoll mode
Not reproducible when the Rigidbody “Interpolate” property is set to “None”
Prioritise and Follow this issue
Have a workaround or additional info about this issue?