- Home /
Why does picking up an object override my rotation freeze setting?
Trying to work in a 2D environment - where the z is fixed.
My Player object has a character controller, and also a rigid body with z position & z rotation frozen.
I attempt to pick up a block with the following code:
private void PickUp(GameObject target)
{
carriedObject = target.transform;
if( carriedObject != null )
{
Destroy( carriedObject.rigidbody );
carriedObject.parent = transform;
carriedObject.localPosition = new Vector3( 2f, .5f, 0);
}
}
It looks like doing this affects the player game object, and removes the "Freeze Rotation Z" from my player entity? When I bump into another object, I start spinning on the Z axis. It seems like no matter how I set the localPosition of my carried object (inside the bounds of the player, outside the bounds, somewhere out in space on the z axis...) I get the same effect.
Is there a tutorial out there I should be following? Does anybody have any pointers to help me "carry" an object? Should I instead be "wearing" the object?
Any advice is appreciated!
Your answer
![](https://koobas.hobune.stream/wayback/20220613112001im_/https://answers.unity.com/themes/thub/images/avi.jpg)