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.
You can disable components like this:
objectHold.GetComponent<Rigidbody>().enabled = false
The other answer is wrong; since
Rigidbody does not derive from
Rigidbody.enabled does not exist. Instead, use Rigidbody.isKinematic to prevent physics from affecting a rigidbody.