Search Issue Tracker
By Design
Votes
0
Found in
2019.4
2020.3
2021.2
2021.2.1f1
2022.1
Issue ID
1379473
Regression
No
Inconsistency between Position values of the Rigid Body and the Transform Components of a GameObject
How to reproduce:
1. Open the user attached "RigidbodyBug.zip" project
2. Open the "TestScene" Scene in the Scenes folder
3. Select the "RigidCube" GameObject in the Scene
4. Change the Inclement setting to 0 in the "RigidBody Mover" Component
5. Press Play and open the Console
6. Leave Play Mode
7. Select the "RigidCube" GameObject and change the Inclement to 0.01
8. Press Play and open the Console
Expected result: Consistent updates of the Transform.position in the GameObject, e.g.: 1,2,3,4
Actual result: Inconsistent updates, e.g.: 1,2,3,2,3,4
Reproducible with: 2019.4.32f1, 2020.3.23f1, 2021.2.2f1, 2022.1.0a15
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
By Design:
" Ensure the Console window has "Collapse" turned off and use the attached script and press play. I've simplified it so the body jumps in whole values right which makes the output easier to interpret. Note that there's a complication here that Unity initially runs a whole bunch of FixedUpdate to catch up with game-time so it's worth looking at it later in the log.
You'll clearly see the before/after Transform position changing within multiple consecutive Update callbacks. Then there's a FixedUpdate callback which shows you the Transform position of the last Update (before) output. This is expected. Then looking at the Rigibody2D position, you can clearly see it's not the same nor is it expected to be yet because the simulation has not run yet and it hasn't synchronized with the user-action of changing the Transform.
At this point, it doesn't matter what you do with the Rigidbody2D because its value is going to be written over by the Transform change. At this point, you're asking two conflicting actions to happen, change the Transform AND change the Rigidbody2D position. The Transform will win here.
To demonstrate this, the attached script simply resets the Rigidbody2D.position as indicated by the console output (after). During the next FixedUpdate or Update, it'll be at what the Transform position was set to."