EndOverlap only fires once
Alright, I'm not English so I'll try my best to explain: I'm currently working on a simple climbing game. Its like an infinite accelerating sidescroller, except that it moves upwards. The player has to jump on spawning platforms to prevent falling down below the screen and losing the game. Super Smash Bros have a few levels like this. The game will keep running until the player dies. This means that the building the player is climbing has to build itself.
I made a blueprint with a mesh (the cubical "room" you can see in the gif), which essentially spawns another actor of the same class a specified amount above itself whenever it hits a trigger parented to the moving camera. Basically, when the wall has reached a certain point on the screen, it will spawn a new one above itself to continue the cycle. Let me know if its hard to understand.
I have attached a gif to make it easier to see, but the file size required is way too small to be practical, so this will have to make do.
Here is the problem: As you can see, a new wall is spawned the first time, but not the second time. The wall is actually ignoring the trigger completely. Keep in mind that it is the camera, floor, and trigger moving upwards, and not the walls moving downwards. The small cubes are present to visualize the movement.
Tl;dr, the self building wall ignores an overlapping trigger, and therefore doesn't spawn a new wall above itself, which breaks the cycle. I'll accept both solutions for the overlap ignore or another method for making the wall build itself alongside the camera.
Here is the blueprint for the selfbuilding wall. The trigger is a box trigger placed in the world, and attached to the camera at beginplay. I'm grateful for any help.
asked Mar 28 '19 at 09:31 PM in Blueprint Scripting
i think your making this a bit too complex for your use case. below i made a simple example of how you could handle your walls in a manner similar to a endless runner (since thats basically what your making). so at the most simple you need an endless stream of floors, this can be done two ways while actually moving the platform as you like. you could spawn new floors as they come on screen and destroy the old as they leave (many ways to do this). or you could just move floors and cycle them, so when one moves off screen you move it to above the screen and reuse it (better performance). ill be looking at the first method since its easy. for this method we will want to spawn a new room once something begins overlapping the current room, so if the platform is overlapping the room then we want to spawn the next one. for this we will need a collision volume (box), you will need your wall mesh, and to be used later you will want a scene component (i added a arrow to show placement). the actual script will be much like yours, on begin overlap spawn wall. in this case we add a little extra check to make sure the overlap isnt another wall to ensure it doesnt spawn more walls than needed. we also use a do once for the same reason, we dont want to spawn a wall bp for a overlap of the character and the platform. another little change was the use of the scene component to determine the new spawn location, this makes things much easier, versatile, and eliminates the need for the math your using. the last bit i included was a way to destroy the wall on end overlap, basically when the wall stops overlapping the player character we set its life span to 1 second meaning it will be destroyed in that amount of time. you may want to use a different method to destroy your wall sections since it seems like your looking to have exponential acceleration, you may need a variable lifespan or a different method.
personally i would incorporate the destroy into the platform and have that as its own bp actor. your platform could incorporate the camera as well then it would be easy to make a very modular setup to have multiple levels.
answered Mar 29 '19 at 12:52 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here