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
- [Vulkan] Crash on with multiple stack traces when rendering large Terrain with specific hardware
- Crash on SkinnedMeshRendererManager when interacting with a prefab generated with uncombined meshes using Synty Sidekick Character Creator
- Crash on folly::detail::safe_assert_terminate_v when updating the Meta XR SDK Packages
- The text font falls back on a different font depending on the fallback font used
- Template is opened in Isolation when opening it in Context and users Save the UI Document when prompted to do so in UI Builder
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.