- Home /
Can someone clarifies OnTriggerEnter, OnTriggerExit and OnTriggerStay for me? (I have image included already)
My main question: A trigger is a zone or a line?
I have two cases:
1) When are the OnTriggerEnter or OnTriggerExit is called - only when the green border is touched ? If I move incredibly fast, passing the greenline (I think they call it tunneling) and then stop completely to stay at zone A - will OnTriggerEnter be called the next frame?
2) Any object with rigidbody and collider staying within zone A is considered "OnTriggerStay"? What if I instantiate an object with RB and collider inside zone A - is that considered OnTriggerStay too?
Unity manual says
but I don't get what is exactly meant by touching the triggerOnTriggerStay is called almost all the frames for every Collider other that is touching the trigger.
Zone. 1.OnTriggerEnter called once a colliders enters(touches the Trigger) OnTriggerExit called once a collider exits the trigger zone. Whatever your speed is OnTriggerEnter will be called once the two colliders touch. 2.Yes. Even with instatiating an object inside a trigger the OnTriggerStay will be called every frame the object remains inside the trigger from the first frame it instatiated also OnTriggerEnter will be called once same first frame. Touching means that they have atleast one common point. If you have problem figuring out how all that works you should create a simple Scene and test how they work or check out some tutorials. Hope that helps, doupt there are more explanations on the matter.