Enabling and Disabling Colliders Unity
- by Blue
I'm trying to make the collider appear every 1 second. But I can't get the code write. I tried enabling the collider under a boolean and putting a yield to make it every second or so. But it's not working(gives me an error: Update() can not be a coroutine.).
How would I fix this? Would I need a timer system and set the collider to be enabled every 'x' seconds and disabled every 'y' seconds?
var waitTime : float = 1;
var trigger : boolean = false;
function Update () {
if(!trigger){
collider.enabled = false;
yield WaitForSeconds(waitTime);
}
if(trigger){
collider.enabled = true;
yield WaitForSeconds(waitTime);
}
}
}