- Home /
Question by
Xylophoyx · Jun 22, 2017 at 10:57 AM ·
scripting problemmissingcomponentexception
"There is no 'Rigidbody' attached to..." but there is!
I would like to clarify I am working in 3D and despite this constant error the rigidbody effects seem to be working fine. Is it a bug? Any help appreciated, thanks.
void PushUp() {
Rigidbody rb = selectedZombie.GetComponent<Rigidbody> ();
rb.AddForce(0,0,10, ForceMode.Impulse);
//The full error: There is no 'Rigidbody' attached to the "yellowzombie" game object, but a script is trying to access it."
Comment
Is rigidbody attached directly to selected zombie or is it on children object?
Answer by Exceptione · Jun 22, 2017 at 02:37 PM
Are you sure the selected gameobject is the exact object that has the rigidbody and not a parent or child?
Your answer