- Home /
Question by
John108 · Nov 30, 2012 at 12:57 AM ·
rotationgameobjectcollider
How to stop a collider rotating with the GameObject
Hey Guys,
I have a few objects in my game that are static but rotate around an axis for aesthetics. What I don't want is the objects Box Collider to rotate with it. Anyone got any ideas about how I could do this?
Thanks in advance, John
Comment
or if you have rigidbody on it you can try
Rigidbody freezeRotationObj = GameObject.Find("objectYouWanttoFreeze").AddComponent<Rigidbody>();
freezeRotationObj.useGravity = false;
freezeRotationObj.constraints = RigidbodyConstraints.FreezeRotation;
Best Answer
Answer by aldonaletto · Nov 30, 2012 at 01:06 AM
You could child the rotating object to an empty game object: delete the rotating object's collider and add a box collider to the empty game object. If you have code in the rotating object to detect collision/trigger events, move it to the parent empty game object. You can keep the rotating code in the child object, since it will not affect its parent. The hierarchy would be something like this:
EmptyGameObject // the collider and associated code goes here
RotatingObject // rotation code can stay here, but remove its collider
Your answer
![](https://koobas.hobune.stream/wayback/20220613084717im_/https://answers.unity.com/themes/thub/images/avi.jpg)