Horizontal scrolling (spanwning and destroy actors)

Hi!

I’m going to develop a shot em up game like Gradius (horizontal scrolling).

For the levels, instead of moving the space ship, I’m going to move the level, spawning the actors which are going to appear on the right of the screen, and destroy them when they disappear. But I don’t know how to do it.

I have thought to have some kind of data structure with the actors, and a counter (or something similar). With this counter I will access the data structure and I get the actors to spawn. And also, another counter to destroy them.

Another option is level streaming.

Are there other options to do it? Or, what do you recommend me?

Thanks.

1 Like

Yes…why not just move the camera?
Your ship actor can have the camera included.

The camera always moves to the right.

The ship is attached to the camera so if you don’t do anything your ship will move with the camera and stay fixed in the screen.

You can clamp the horizontal location of the ship so you have limits in the screen you can’t surpass.

you can put two box colliders in the same camera/ship actor: one is in front, outside the camera view (far right side) that ACTIVATES the other actors (enemies/powerups/whatever

other box collider behind, outside the camera view too that will destroy the elements left behind.

For scrolling you move the whole ship/camera/colliders actor.

Good luck!

Dany

Here is some practical example:

The ship blueprint should look something like this:

For scrolling you scroll the whole actor

I added some action keys in the settings for moving the ship and the movement is clamped so the ship wont leave the screen zone like this:

image

here is the logic for moving the ship:

the other object actors have an ID tag so the end colliders of the ship can detect them and react.

this is the other actors tag:

image

then in the ON Begin Overlap Event of the ships collider I activate the other actors at the start and destroy them at the end like this:

Here is a short video I prepared for you just showing this method:

Hope it helps!

Best,
Dany

3 Likes

Hi!

@eldamy.uy Thanks a lot for your answer.

I don’t know which the colliders actor are? Are they an actor with a box collision component?

Thanks!

go to the actors components you want to ignore collisions and set collision preset to no collision

image

Thanks, but I was asking: what is an actor collider?

The colliders that appear in the image above.

I think they are two blueprint classes with a Box Collision.

Thanks.

Actually in that example, the ship actor includes two box collider components:

image

OK. Thanks.

So, there are two Box Collision Component, and you use the Overlap event to detect when an “enemy ships” overlaps the box.

Sorry, but I’ve just started and I don’t know everything.

Thanks.

yes…The concept is to have a Ship actor that moves to the right,the ship holds two colliders to enable the enemies in the stage…enemies are standing in the level and are enabled when the starter collider hits and then when ships hit the end collider then they are destroyied because they are left behind

Sorry, I have another question. How do you move the ship without moving the box colliders?

As far as I know, If I move the BP_Ship with SetActorLocation. then I will move the Ship_Body and both Colliders.

Maybe you are moving the StaticMesh that represent the space ship with the Add Actor Local Offset function.

Thanks a lot!

Exactly…I am moving the Ship_Body (clamping the axis borders the keep the ship inside limits)

1 Like

Hi Eldany,

thank you for your explanaition. I am trying to build the same logic, but some things have changed in UE 5.2. I don’t get the scrolling movement to work with the new enhanced input system and there seems to be a new mechanism for the clamping.

If you find it in your heart to help again, it would mean so much to me.

Cheers

Maybe you still have the old project and could upload it to a google drive or something, so I could have a look at it, please?