Applying a Rigidbody with C#

So far I’ve got this.

        GameObject colSphere = GameObject.CreatePrimitive( PrimitiveType.Sphere );
        colSphere.transform.position = node_.getGameObjectPosition ();
        colSphere.transform.localScale = new Vector3(7.0f,7.0f,7.0f);

I tried this code to apply a Rigidbody to my object but it won’t work because there is no rigidbody to access.

colSphere.transform.GetComponent<Rigidbody>().enable = true;

AddComponent() is probably what you’re looking for. :slight_smile:

Cheers

1 Like

That works, i feel silly for asking now. Thanks.
Any chance you know how to check if it’s colliding with anything else?