Newbe Question: how to keep a Boolean true over multiple trigger box

I know this must be a very basic thing but I am trying to keep a variable value to true over multiple trigger boxes, I set the value to True when entering a trigger and would like to keep it True as long as I stay inside a zone defined by multiple triggers.

My problem is when I enter the first trigger and then leave it to enter the next one, the “On Actor End Overlap” gets triggered after the “On Actor Begin Overlap” and setting the value back to FALSE even if I am in the second trigger where the value would normally be set to true. I tried with a delay when entering the second trigger so the Begin Overlap gets called a bit afterward but I can find a way to break it pretty easily if I go back and forth in a corner between few volumes.

I could use triggers all around the zone to set back the value instead of setting it off in the End Ovelap function and that would work but I feel this is pretty dumb and I cannot believe there is no easier way…

Or maybe use and Even Tick in the level blueprint and check every tick if the player is in one of the trigger box and then automatically set the value if it is, but again I feel its a bit overkill for such an simple thing.

Any help appreciated.

cheers!

A simple suggestion: create a manager that binds to the begin/end overlap of each trigger. On begin overlap, increment an int; on end overlap, decrement it. If the int reaches 0, it means the player has left all triggers.

thanks, I actually fixed it by using another bool following a similar logic, if the player is already in a trigger previously it gets set to true and the On Actor End Overlap does nothing is the character was already inside, It broke my brain tho. I will use your method next time I think its more easy to comprehend that way. Cheers!

1 Like