Spawning and Destroying Actors causes massive performance loss

Hey All, I have a simple BP set up where I’m loading in a static mesh cube every .01 seconds. This ends up creating a “trail” of cubes behind my character (around 3,000 or so). I’ve set a life span on the cubes so that after 15 seconds, they destroy themselves. The intent is to hide the cubes when playing in game to create a collision “ribbon” behind my character. The issue is, once the cubes start to destroy themselves, I get a massive drop in performance (20-30 frame drop). I’m assuming the issue is the number of draw calls and the fact that UE is trying to spawn in and destroy thousands of boxes at once. Does anyone have any suggestions? Here’s a video showing the issue;

Yeah, you do not want to do that with actors. I’d make each line a single mesh, scale it and manipulate its material - that’d be optimal and very performant. But tricky to set up.


Try Instanced Static Meshes instead - they’re plenty fast for something like this. And 3k ISMs is nothing.

  • an actor that spawns them:

  • this actor is attached to the player pawn via a Child Actor Component:

This CAC is critical here and also the reason why the Spline Mesh Component’s collision did not work (the one from the forum’s DMs). The entity that creates them has to be an actor that is separate from the Pawn. Otherwise the Movement Component will ignore it as it only takes the root into account when calculating collision.

If you went with the spline + SMCs inside a Child Actor Component, it should work OK, too.


Image from Gyazo

To dramatically improve performance of the ISMs, disable their shadow casting. Although I wouldn’t expect issues unless you go into tens of thousands.

Also, do not try using Hierarchical ISMs for this. The indexing will become an order of magnitude more difficult if at all manageable.

Also, this would work really well with procedural mesh - but that’s a significant upfront cost of setting it up and figuring out how it works.

Short and neat intro:

edit:

@Tefel - ha, your 5 year old tuts are still handy. Also, shameless plug: Astro Colony

Thank you for the screenshots! Unfortunately, after setting up my ISM and Character BP exactly how you have it, nothing spawns behind my character! Do you see anything that I did wrong in the video below? Thanks!

Linking it the other way now:

We need a better system ;p @EpicGames