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
- Reference to a deleted GameObject becomes "None" instead of "Missing" when the GameObject is restored with undo after entering and exiting Play Mode
- Size value in Particle System Curve's tab is highlighted with selection across all tab header
- Particle System Curve's Presets window has no visual indication of what preset is selected
- Blur shader doesn't work when the "Scene Color" Node is attached to the UI "Output" Node
- Particle System Curve presets can't be scrolled and some of them can't be selected if window is too narrow to fit them all
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."