OnTriggerExit2D calling twice.

Why does OnTriggerExit2D call on the first exit of the trigger and the second? In other words. Say you have a square passing threw another square. The trigExit will call when the top of the square leaves the trigger then again when the bottom of the square leaves the trigger. How can i make it not call untill the bottom side leave (aka the whole object, and not just one part of it then again when the whole object leaves)

2 Answers

2

Its because i had multiple colliders on my character, so it was being called for each collider that entered and exited.

You could add tags to the colliders, or you could just make the trigger not fire twice per parent object that enters it using a variable check in the class itself

Unity doesn't show you how much of you GPU is in use. It shows times how long it took to render frames. 16ms would be around 60fps. If you let it run for a while scale should change so it's not showing constantly full bar. As you can see from the bottom there is "PlayerEndOfFrame" that took 101.34ms to complete and that is much taller than the 66ms profiler is showing. One reason for GPU to be on low usage is that it's just waiting for CPU to complete its task. And CPU might do pretty much everything on single core, depending on multithreading of your project.

Hi, did you ever figure it out?

Its because i had multiple colliders on my character, so it was being called for each collider that entered and exited. You could add tags to the colliders, or you could just make the trigger not fire twice per parent object that enters it using a variable check in the class itself