Hello Guys! I’m new to unity, and I’m having a problem! I want to turn off the Capsule Collider from a GameObject via JavaScript, wait a few seconds and turn it on again, but i don’t know how to turn it on or off… can you guys help me?
#pragma strict
function Start () {
}
function Update ()
{}
function OnCollisionEnter(hit : Collision)
{
if(hit.gameObject.tag == "ClimbHighTrigger")
moverparaheroi.colisao = 0;
********TURN OFF CAPSULE COLLIDER HERE******
yield WaitForSeconds (3);
myComponent = true;
********TURN ON CAPSULE COLLIDER HERE*******
moverparaheroi.colisao = 1;
}
But if you want a trigger, just check its Is Trigger checkbox.
NOTE: This code turns on/off the collider of the object it’s attached to. If you want to disable the other object’s collider, use hit.collider.enabled instead.