How can I check collision in capsule collider when I want?

Hi friends,

How can I check collision in capsule collider when I want?
Regards,
vanhouten777.

Hi LeftyRighty
Thank you for the reply.

Regards,
vanhouten777

been thinking a little more about this one… specifically the “when i want” bit…

those functions get called by the unity engine when it works out there is a collision. If you’re looking to have some logic elsewhere which, for example, asks “am i on the ground?” you’ll need to setup a variable which gets updated by the collision functions above (and they’re respective exit functions etc) so you have something you can check against.

I think the character controller component does something similar with it’s “isGrounded” var. Unity - Scripting API: CharacterController

Hi LeftyRighty ,

How can we add a script to variable object like var CC : CapsuleCollider?
Regards,
vanhouten777.

CapsuleColliders are components attached to GameObjects
Scripts are also components attached to GameObjects

if you want to access other components attached to a gameobject in a script have a look at the scripting reference guide pages:

http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Components.html