Search Issue Tracker
By Design
Votes
0
Found in
2017.4
2019.3.9f1
2020.2
Issue ID
1237233
Regression
No
RigidBody Constraints are not applied when a Collider is added at runtime when Instantiating GameObject at specific positions
How to reproduce:
1. Open tester-attached project (ConstraintsBugRuntime.zip)
2. Select the 'PlayerSpawner' GameObject
3. Next to the 'Bug Option' drop-down select 'Get Component'
4. Enter Play Mode
5. Select the Sphere in Scene View to see its positional gizmos
6. Note that the Sphere's rotational constraints are applied
7. Exit Play Mode and change the 'Bug Option' drop-down to 'Add Component'
8. Enter Play Mode and check the constraints again
Expected result: the Sphere's rotational constraints are applied
Actual result: the Sphere's rotational constraints are unapplied
Reproducible with: 2017.4.40f1, 2018.4.22f1, 2019.3.13f1, 2020.1.0b8, 2020.2.0a10
Notes:
Changing the Spawn Position vector Y value from 0.35 to 0.5 oddly prevents the issue
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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
Resolution Note:
Constraints work in the inertia space (relative to the inertia tensor rotation), and the case it appears to be working wrongly, the inertia tensor rotation is actually (0, 0, 45) instead of (0, 0, 0).
As to the reason why the inertia tensor rotation is different in these two cases -- observe that the Collider centers are different too. Those centers are matched to the AABB of the renderer if it's present at the time the Collider component is initialized. In this case, there appears to be a very slight difference in the centers, but it is enough to produce different rotations already. I suggest to either have Collider and Renderer on different objects, or reset the center of the Collider from scripts.