Something has broken since updating to 2018.2: a child collider seems to lose its local position and be transformed in global space.
In the video below, you see the scene view, when I click the building, it lights up and the collider starts moving away from the building (because it’s now in scene space).
RepentantGregariousArmyant
Before I updated to 2018.2, this worked. I have not changed the code (below) since the update. Here it is working before the update:
I have a non-kinematic rigidbody that has forces acted upon it. It has a few children that control the placing and clicking of buildings and then each building has a child collider with a rigidbody. So the structure is:
-
Main Cloudship Object [RigidBody]
-
Building Surface that controls object placement [No rigidbody]
-
Building [No rigidbody]
-
Box Collider [Collider and Rigidbody set isKinematic = true]
-
(There is another kinematic collider but we don’t care about that here)
The Rigibody is required on the Box Collider because I need the Box Collider to raise trigger events (the Collider is set to Is Trigger = true) for overlapping other buildings. I’ve read that you shouldn’t have rigidbodies as children of other rigidbodies without a hinge but in this case, it’s only kinematic for the raising of events. I don’t ever change the transform of the Box Collider, only that of the parent building.
When I click-and-hold a building, the following code sets the transform to the place under the cursor:
Vector3 localPosition;
if (GetDesired(out localPosition))
{
selectedBuilding.transform.localPosition = Vector3.Lerp(
selectedBuilding.transform.localPosition,
localPosition,
Time.deltaTime * 40);
selectedBuilding.IsOverCloudship = true;
}
I know that this code is correct because the Building object (the mesh) stays in the right place (you can see the result of it in the top video, it’s the red line). It’s the collider children that move. The Lerp isn’t important here, removing it causes the same effect.
Was there a change in 2018.2 that I missed? A more strict constraint perhaps?
I’m completely stumped, thanks in advance for your help!