- Home /
Remove rigidbody component
I am trying to disable the rigidbody constraints on my project on the click of a button, but I'm havbing a bit of trouble.
So far this is my code:
var constraints : RigidbodyConstraints;
function Update () {
if(staticvar.cleardisc == true) {
print("working");
constraints = FreezeNone;
}
}
So the code does print "working" which means the static variable is fine, however I'm not sure what I should write to make all the constraints disappear. I've tried constraints = false and constraints = 0 too but it didn't help me
Any help would be appreciated :)
Answer by syclamoth · Nov 08, 2011 at 05:41 AM
You're looking for
constraints = RigidbodyConstraints.None;
However, if you are trying to remove the Rigidbody altogether (as the title suggests), you should use
Destroy(rigidbody);
I don't want to destroy the rigidbody I want to stop the freezeyposition component so it will begin to fall. Can you tell me what I'd write to do this?
Is this in relation to your other question? In which case, I think you have other problems on your hands!
Yes it is in relation. So if I have y axis constraints I can't remove them?
Yeah you can. This is what
rigidbody.constraints = RigidbodyConstraints.None;
does.
Thanks i had to add the 'rigidbody.' at the start :) Thanks again
Your answer
Follow this Question
Related Questions
How do I query the RigidbodyConstraints? 3 Answers
Rigidbody Freeze Contraints Not Working 2 Answers
rigidbody constraints no longer part of unityscript or something? 2 Answers
Can you unfreeze a rigidbody.constraint position as you can freeze them? 2 Answers
Disabling Rigidbody constraints on GameObject that script is attached to 3 Answers