Why does my actor count keep increasing, even though I call destroy?

Hey, so I’m currently working on my first endless tracking shot for a music video, using what I learned in the official endless runner tutorial. But somehow my actor count keeps creeping up by the amount of actors+children actors.

This is my BP for creating and destroying said actors:

What am I missing, why does the count keep increasing, even though they disappear from the viewport and outliner?

you only destroy the last actor of the array because you connect the destroy actor in “completed”, you need to connect the destroy actor to the “Loop body”

1 Like

Hi there,
Try these changes:

Hey, thank you, I implemented these changes, but the actors still keep piling up.
It has no effect on the performance even with 2k actors, but I’d rather keep the scene tidy.

I’m completely at my wits end. My scene recently started slowing down as soon as I hit the 1000 actors mark and I still can’t figure out why the actors keep piling up and aren’t destroyed.

I’m a bit unclear on what you are trying to do. Are you trying to create an actor and then destroy it 2 seconds later?

There could be mulitple different reasons why this is happening:

  1. There is an spam of overlap events
  2. The cast fails
  3. You are destroying the actor which may be needed
  4. Other stuff
1 Like

? You say they disappear from the outliner and the world view?

In that case, why do you think they aren’t being destroyed?

Currently working on an endless tunnel, so I’m basically destroying the [0] in an array of nine tunnel pieces after the camera has passed it, and adding a new one at the end.

Already checked for the cast failing, that is not the case, will check for spam of overlap events next, thanks!

You made me realize a mistake I made, I thought they were being destroyed, because they were disappearing from the outliner, but just now i double checked and expanded the outliner.

This is what I’m greeted with.

So some are being destroyed, but seemingly at random.

I’m probably missing something really obvious, will rig all blueprints with print functions to finally get behind this and check back in.

Thanks y’all

Currently working on an endless tunnel, so I’m basically destroying the [0] in an array of nine tunnel pieces after the camera has passed it, and adding a new one at the end.

Well, I see that your camera actor is capable of overlap. Are the actors you want to delete also able to overlap? You could just have them call destroy on themselves on Actor End Overlap.

If I understand correctly, it is just a camera going forward, so you are just deleting the tiles after it passes them right?

I also notice some other things:

  1. Your destroy is tied to “completed” pin rather than the loop output. Posters above already told you about this, so I’m assuming you changed it.

  2. You are using a for each loop rather than a reverse for each loop. If you want to destroy an actor, you usually have to use the reverse for each loop rather than the regular one. This is because deleting actors in an array screws up regular for each loop.

That’s what I’m currently doing, the whole destroying process is part of the floortile_bp, just the adding of more tiles is cast to the camera.

I just figured out what I did wrong though, there were 2 collision boxes inside my camera actor, instead of just one.

So begin overlap events as well as end overlap events would be called twice and that’s what caused my actor count to climb. Thanks again.

It would certainly be more performant if you just moved the actor to the end, rather than destroying and creating a new one.

another technique would be to actually move the tunnel rather than the camera