- Home /
Question by
IMTRIGGERHAPPY9 · Aug 03, 2011 at 04:14 AM ·
ontriggerstayexitenter
OnTriggerStay/Enter/Exit for a second time?
how to do you get all of the OnTriggerEnter/stay/exit to search even after they have been activated. because currently my object is sensing everything properly but then stop searching as soon as it leaves. so when it enters again it does nothing. so how do i fix this to search for it a second time to ?
here is my code currently
@HideInInspector
var targetAquired = false;
function OnTriggerEnter (other : Collider) {
if(other.gameObject.CompareTag ("enemy")){
targetAquired = true;
print("targetAquired");
}
else {
targetAquired = false;
print(targetAquired);
}
}
and then the exit code:
function OnTriggerExit (other : Collider) {
if(other.gameObject.CompareTag ("enemy")){
targetAquired = false;
print(targetAquired);
}
}
Comment
Best Answer
Answer by Eric5h5 · Aug 03, 2011 at 04:16 AM
Nothing to do with OnTriggerEnter and so on, just turn off "collapse" in the console.
omg i dont know what i would do with out this resource sometimes..... i feel like such an idiot. THAN$$anonymous$$ YOU A TON!
Your answer
![](https://koobas.hobune.stream/wayback/20220612165135im_/https://answers.unity.com/themes/thub/images/avi.jpg)