How to use OnTriggerStay?

How might I use the OnTriggerStay function to perform something when a collider is in a trigger? Nothing seems to happen with the function on its own.

I know with OnTriggerEnter and OnTriggerExit, you’re required to register a collider for that event beforehand with trigger.TriggerEnter += OnTriggerEnter, etc. And there only seems to be trigger.TriggerEnter and trigger.TriggerExit, but not a trigger.TriggerStay. Is there a way of registering a collider for that OnTriggerStay event or is there something else I need to do? I hope this makes sense .

We don’t have TriggerStay event due to performance reasons. It was deprecated in Flax 0.5 (October 2019).
As you’ve said, you can use combo of OnTriggerEnter + OnTriggerExit to register active trigger and use it in OnFixedUpdate.

2 Likes

Ah, okay. I can see how it could be a performance issue. Thanks for the super quick reply!