SpawnActor alternative when you need to keep the framerate

Hi.

I’m trying to leave a visual mark on a given location every time you press the trigger. Right now I’m doing it via SpawnActor from class, which spawns a very cheap box_BP (static mesh).

The problem is that as soon as I reach 4 or 5 spawned actors, the framerate goes to hell real quickly. I thought that spawning instances could be cheaper, but it doesn’t feel like that.

So, which could be the best way to spawn visual marks (as simple as a box) at selected locations when the user presses the trigger and keep the framerate reasonably high?

Thanks!

You could give the spawned actors a life span value, disable collision, and disable physics. Out of curiosity how did you spawn an instance of something? I’ve always just used spawn actor from class.

@plasma_450 Yes, I’ve found spawning no problem, could be something fishy going on… what do you have in that boxBP?..

To be more precise I’m in VR, so the framedrops are very noticiable.

I’ve just moved the small room to a new streaming level unloading the rest to be sure there’s nothing tanking my framerate outside this room. Doing this made things better, but not too much. Or at least not as I was expecting. The moment I spawn 20 marks, the FPS drops noticeably. I know actors are pretty expensive, but man, those are just bare boxes.

The spawned BP is just a box (statich mesh actor) with an unlit simple RGB color material and no casting shadows. Lights inside the room (2 static) are set to the bare.

Spawing an actor consumes memory and allocating the mesh inside the level takes some time. I’ve count that 30 boxes kill the 80fps to 40fps. And leaving the boxes floating there keeps the framerate low. (At Oculus you can see the stats FPS and the headroom you have at every second… and yes, I know the 40FPS are forced by Oculus one the FPS drops well below the 80fps… at least on Rift S)

Thanks for any idea you could throw as I’m a little lost, to be sincere.

If framerate is still low even after spawning is done, your problem might be in the materials you use and not really about actor allocations.

Anyway, this still might be helpful to you since was built for platforms where maintaining a stable framerate (like VR and Mobile) is difficult:

https://forums.unrealengine.com/unreal-engine/marketplace/104929-plugin-object-pool-component?132287-Plugin-Object-Pool-Component=

Keep in mind that this system is not network replicated though.

That Pool plugin you talked me about led me to think about creating a pool of 200 BP references inside the level manually, and then moving them as desired simulating a creation… then, placing back to the original location (out of sight) when I wanted them to disapear instead of spawing/destroying actors realtime.

Great solution :slight_smile: now, with those 200 actors already in the level when I stream-load it, evertything goes smooth as silk (still 70% headroom margin before the ASW kicks in due to several framedrops) . Thanks for pointing me to the idea, .

Regards!