# Horizontal scrolling (spanwning and destroy actors)

**URL:** <https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, CPP, question\
**Created:** [May 14, 2022, 8:05am UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901 "2022-05-14T08:05:55Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [May 14, 2022, 8:05am UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/1 "2022-05-14T08:05:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [May 14, 2022, 11:42am UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/2 "2022-05-14T11:42:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [May 14, 2022, 12:52pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/3 "2022-05-14T12:52:55Z")

</div>

Here is some practical example:

The ship blueprint should look something like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/7/2376478ff04352cd8cd001126cff73f123360abc.jpeg)

For scrolling you scroll the whole actor

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/6/336e3d945b82f0e5c7133a3400ae1b6fde08b749.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/c/f2c5791d08fe90f41163a946906ea9606bff96fd.png)

here is the logic for moving the ship:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/4/3f43f8a0b02768865880cfc3194b13d2642f8045.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/8/a1800fd46ca142d1966d4b289733e006817e73d7.png)

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/c/a0ca9aca5d02540b1bc732c59a19082df80fce3d.png)

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

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/2/d22897588b1ef6f1d3c5037fb7b7631e5751eb58.jpeg "Unreal basic scroller setup") ](https://www.youtube.com/watch?v=UW1z19k0Smg)

Hope it helps!

Best,  
Dany

---

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [June 8, 2022, 2:59pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/4 "2022-06-08T14:59:29Z")

</div>

> [@eldany.uy](#):
>
> colliders actor

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!

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [June 8, 2022, 3:29pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/5 "2022-06-08T15:29:16Z")

</div>

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/2/402c483677f428c4e5397b03b3cb85e20c0788df.png)

---

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [June 8, 2022, 3:57pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/6 "2022-06-08T15:57:39Z")

</div>

Thanks, but I was asking: what is an actor collider?  
[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/7/2376478ff04352cd8cd001126cff73f123360abc.jpeg) ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/7/2376478ff04352cd8cd001126cff73f123360abc.jpeg)

The colliders that appear in the image above.

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

Thanks.

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [June 8, 2022, 4:34pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/7 "2022-06-08T16:34:05Z")

</div>

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/5/7c5bd7d16da29aa1d93d5583543421cf97dd326f.png)

---

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [June 8, 2022, 4:48pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/8 "2022-06-08T16:48:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [June 8, 2022, 4:59pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/9 "2022-06-08T16:59:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [June 9, 2022, 9:48am UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/11 "2022-06-09T09:48:01Z")

</div>

> [@eldany.uy](#):
>
> Actually in that example, the ship actor includes two box collider components

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

 ![imagen 476x500](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/6/5964829167e1bf5f1586a4ed625993fe91edf989.png)

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!

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [June 9, 2022, 9:55am UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/12 "2022-06-09T09:55:23Z")

</div>

Exactly…I am moving the Ship\_Body (clamping the axis borders the keep the ship inside limits)

---

<div class="post-metadata">

**Author:** ![rockshurt75](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rockshurt75/32/710355_2.png) [@rockshurt75](https://forums.unrealengine.com/u/rockshurt75)\
**Post date:** [June 5, 2023, 3:20pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/13 "2023-06-05T15:20:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rockshurt75](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rockshurt75/32/710355_2.png) [@rockshurt75](https://forums.unrealengine.com/u/rockshurt75)\
**Post date:** [June 5, 2023, 3:21pm UTC](https://forums.unrealengine.com/t/horizontal-scrolling-spanwning-and-destroy-actors/556901/14 "2023-06-05T15:21:28Z")

</div>

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?
