- Home /
Question by
PUNstoppable · Jul 17, 2018 at 12:37 AM ·
ridigbody
Disabling a rigidbody
I'm making a game that has a grab and drop mechanic. I managed to write the code to grab the object, but because the object has a rigidbody, I am unable to hold the object and look straight up. Is there a code that disables a component in the gameObject when the gameObject become the child of an object tagged player? Thanks.
Comment
Answer by m0guz · Jul 17, 2018 at 04:30 AM
You can disable components like this: objectHold.GetComponent<Rigidbody>().enabled = false
Answer by JimmyCushnie · Jul 17, 2018 at 04:39 AM
The other answer is wrong; since Rigidbody does not derive from Behaviour, Rigidbody.enabled does not exist. Instead, use Rigidbody.isKinematic to prevent physics from affecting a rigidbody.
Your answer