Setting Sphere Collider radius via script help

I have followed the docs and read some posts and I still can’t nail how to change a sphere collider’s radius via script.

I have this:

	obj.GetComponent(SphereCollider);
	obj.collider.radius = 0.35;

… it will run on the Editor but it will not compile.

Instead it will prompt me:

'radius' is not a member of 'UnityEngine.Collider'

Any ideas?

You’re not storing your SphereCollider. Try something like:

SphereCollider sphereCollider = obj.GetComponent<SphereCollider>();
sphereCollider.radius = 0.35

Ah! Fantastic! It worked!!! Thanks a bunch!!!

thanks elveatles:slight_smile: