I’m working on a prototype topdown game, specifically the loading various sections of the world. I can’t really use Streaming Volumes, because since the camera is offset far away from the character, when in a building with multiple floors, for example, the camera enters the first floor while the pawn is still on the ground one. So I decided to load stuff in with triggers and blueprint.
So what I’m doing, is have a trigger just for loading (OnActorBeginOverlap followed by Load Stream Level with “Make visible after load” ticked off"), and then another trigger for visibility. Now I want the visibility trigger to make the sub-level both visible and invisible, so I did this in the level blueprint:
I get the Streaming level, check if it’s visible, the if it is, when the actor crosses the trigger, it’s made invisible, if it’s invisible it’s made visible. I mean it’s a simple if-else.
I placed the trigger on top of some stairs. The problem is that when the character enters the trigger, it fires more than once, so it goes false-true-false-true really quickly for a few frames and then it stops, not always in the right way. This also seems to happen only when going UP the stars, when going down it seems to work fine, the OnActorBeginsOverlap fires just once.
The character is just the example top down character from the template. Other triggers I’ve placed (for example the loading one) seem to work fine. What is happening?
Overlaps are not a ‘neat’ thing. You can count on it firing many times and unpredictably as you move in and out of the volume. So, a couple of things:
You need to cast to your player, otherwise it will fire on just about anything overlapping with it. It might not seem necessary now, but you find it a problem later as the level becomes more complex. For instance if you use overlap near a moving door, the door will also cause the overlap.
When you get the overlap signal, go directly into a DoOnce node to stop it firing again. Then you can deal with the overlap. You can reset the DoOnce when you get the end overlap signal.
I’ve tried something like this, also with trigger volumes instead of boxes, but in both cases I get some strange behaviour. Whenever I go UP the stairs with the player character, both OnActorBeginOverlap and OnActorEndOverlap fire at the same time when I touch the trigger, and THEN OnActorEndOverlap fires again when I leave it, and I still get the same on/off/on/off flicker. But whenever I go DOWN the stairs, OnActorBeginOverlap fires first, and then after a bit OnActorEndOverlap fires, in the correct way.
I thought that maybe the trigger box/volume was too thin, so I would have the head outside of the box while the feet were still inside and it would mess it up, so I made the volume bigger, but I still get the same behaviour. It’s really strange that it happens only when I go up, and not down.
Yeah I was thinking about doing this, I just liked having a single trigger for it. I mean, in my mind I can’t see WHY this would not work. I tried moving the volume on the ground, and if I approach it from the sides, the events fire fine. Ascending in a diagonal way seems to mess the trigger up somehow. I wonder if it’s intended behavior or a bug?
As an addendum, I added the other triggers in order to reset the DoOnce node, they exhibit the same behavior when ascending, they fire more than once. It doesn’t matter in this case, because they don’t have a visible effect in game, but a bad positioning might result in bugs too.
It’s not a bug. The assumption that overlap happens once is incorrect.
Try doing a print on overlap, and boogieing around in the box area, it happens unpredictably.
You can’t expect the player to just run through the box, they may well pause, especially at the top of some stairs. You need to have a rock solid system, one way or another you have to limit the level spawning to ‘1’.
Whether you do that by controlling the collision, or by only loading/unloading the level when it’s not already loaded etc, is up to you…