I’m making game that will create a force field around an area if you turn on a certain light, I want this force field to kill all things tagged respawn that touch it. I have all the code working except that when you turn on the light, if a monster is already inside the forcefield the monster does not die unless it goes outside and then back in. I think this is because I use an OnTriggerEnter function, so it doesn’t run again if the if conditions are fulfilled. It only runs when they enter. Is there a different way I could do this?
just incase it is hard to grasp my question here’s my code, it works fine.`
var Monster : GameObject;
var lightObject : Light;
function OnTriggerEnter (other : Collider) {
if(lightObject.enabled == true){
if (other.CompareTag ("Respawn")) {
Destroy (other.gameObject);
Instantiate (Monster, Vector3( -60,-13,70), Quaternion.identity);
}
}
}