I have the following code:
void OnTriggerStay() {
if (paused == false) {
paused = true;
renderer.material.color = Color.green;
} else {
paused = false;
renderer.material.color = Color.blue;
}
}
What I would like to do is to have the trigger set pause to true and then next time to false.
This works but only sometimes. Usually when the trigger is fired the object color changes from one color to the other and then back almost straight away. Is there a way I could add some hysteresis to this so that it can’t immediately change back for a short time?