- Home /
Rigidbody Rotates When Getting a Child
Setup
I have an capsule object (Player) with a Rigidbody with all rotation constraints locked. Player has an empty GameObject (ItemHold) with a position.x of 1.1, where I'd like held items to be. An item has a Rigidbody with all rotation constraints locked and a sphere collider. The item has a child with a trigger collider used to determine when the item is in range to pick up.
On button press, if the item is in range, its Rigidbody is removed and it is parented to ItemHold.
What's Wrong
When the item is moved into the Player hierarchy, the Player rotates a slight amount (usually around 0.5 degrees) around the Z axis.
What Else I've Tried
Remove all SphereColliders on Item when picked up.
Remove Rigidbody/Collider when Item becomes stationary on the ground. This helped, but there was still an error which could add up over time.
Resetting Players rotation after the parenting. This had no effect.
The only other thought I have is to zero out the rotation in an Update on a Player script, but this doesn't seem very efficient. Is there anything else I could be doing?