- Home /
Question by
HariKrishnan · Jan 10, 2014 at 01:25 PM ·
collidercharactercontrollerboxcollider
how to disable the character controller and box collider for after hitting the character controller
if(hit.gameObject.name=="Red2")
{
//print("Hit");
hit.gameObject.collider.enabled=false;
hit.collider.enabled=false;
yield WiatForSeconds(1);
hit.gameObject.collider.enabled=true;
hit.collider.enabled=true;
}
This code using to enabled and disabled.but the process is continuously in the scene. each and ever one seconds enabled and disable process is occurred.
I need only one time of hitting after occurred the enable and disabled
pls help other.
Comment
Answer by HariKrishnan · Jan 27, 2014 at 06:07 AM
if(hit.gameObject.name=="Red1" || hit.gameObject.name=="Red1(Clone)") {
if(penetrate!=0 && ene2!=1)
{
//hit.collider.enabled=false;
hit.gameObject.collider.enabled=false;
hit.collider.enabled=false;
yield WaitForSeconds(0.5);
hit.collider.enabled=true;
hit.gameObject.collider.enabled=true;
ene2=1;
}
if(ene1!=0 || ene3!=0 || ene4!=0 || ene5!=0)
{
ene3=0;
ene1=0;
ene4=0;
ene5=0;
}
}