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

Physics

-

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

  1. 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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.