- Home /
Can you use triggers in script?
I don't mean the animation triggers but instead of using a bool, but have something like if enemy is detected trigger this action, move to this position. So my question is what are some different ways of having something happen in script?
Answer by JoshuaMcKenzie · Oct 09, 2015 at 03:08 PM
The first thing that comes to mind is using colliders set to triggers and having a monobehavior with the methods OnTriggerEnter,OnTriggerStay, and OnTriggerExit. There is a tutorial here. For triggers that are more about an objects state changing and less about moving into a collider's trigger zone, you can also look into events and function delegates.
Answer by FortisVenaliter · Oct 09, 2015 at 02:32 PM
Well, the normal way would be function calls. You need to trigger functionality, you call a function.
Short of that, use a bool. If it's set, then run your functionality and set it to false.
Your answer
Follow this Question
Related Questions
How can i reverse all the booleans in a method? 2 Answers
Translate Jump Trigger Collision Issue 1 Answer
Can I make A trigger, Trigger the OnTriggerEnter Function 1 Answer
Make an object a trigger? 1 Answer
Raycasts not working on triggers. 2 Answers