- Home /
Answer by VioKyma · Sep 10, 2013 at 06:35 AM
Check this out to freeze specific axis: Rigidbody Constraints
To freeze the X axis use this code:
rigidbody.constraints = RigidbodyConstraints.FreezeRotationX;
If you need to apply this to a child, they will already have a rigidbody (otherwise, you don't need to do this) so just reference the child's rigidbody and execute the same code on it.
So if you want to freeze the Y and Z axis, use: rigidbody.constraints = RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
I didn't tried it. I am thinking now of something else. Anyway I will accept this as correct!
Answer by 87morpheus · Sep 09, 2013 at 07:01 PM
You can either do that by code or just simply add a rigid body on it and freeze the axis's you want. I don't know if the rigidbody will work on a child, but you can try it.
That's why I asked question. I don't know how to do that by code. And you can't freeze rotation/position that don't work on a child. But anyway thanks.
I'm sorry I can't answer, I'm on my phone right now and I'm pretty busy, I'll try to get you the answer tomorrow.
Your answer
Follow this Question
Related Questions
Local child rotation and transform.LookAt 2 Answers
Get rotation around (forward) axis ? 1 Answer
fixing rotation on a specific axis 1 Answer
Freeze an Axis Rotation Help? 0 Answers