Actors hidden in game and performance

I apologize in advance if I’m asking this in the wrong category. My question is, how much do actors that are set as ‘hidden in game’ decrease performance? Is it okay to have many hidden actors stored somewhere, and make them visible when they are needed? Or would it be better to only remember class references and spawn actors when necessary?

That depends.

If actors have any blueprint connected to on tick event. Then around 200 of them makes everything slow. Also for mobiles that number goes down to around 20-30.

So it is better to spawn actors in runtime.

Thanks for your reply, that was really quick. Does that mean if I don’t need the actors to do anything on event tick, it’s okay to do it this way?
To elaborate, I’m creating an inventory system and I’m debating how to store items. Either I can remember their class references, or spawn them all somewhere and only make them visible when they’re used/equipped. I worried the latter solution would be quite bad performance-wise, but it would certainly make a lot of things easier for me.

Don’t remember the class references but rather remember the classes. Spawn them from Class when you need them. Remember that a reference still uses space in memory … so although you might not see a performance hit from lots of objects, your game will still use more memory if you are storing the references.

Rather spawn and destroy as you need, this will allocate and free up memory.

1 Like

Very well, I’ll try. Again, thanks a lot for your help.

It depends on how many actors you want to store and how much data is in each. At a certain point the number of actors will cause the engine to stutter due to memory issues.

I ran a test where I spawned hundreds of thousands of invisible actors and it is fine up to a point. When I increased the data in each actor to 1-5MB the limit became much lower, though I can’t remember off the top of my head where that limit was at. That was on a fairly decent PC, so mobile is going to have a much lower limit.

1 Like

this fireballfunctionality
PIE testing, two windows, server and client, this processor and this video card
FPS go down from 40 with bouth window open side by side(like in video) to 28(every ~300 instantly drop ~3fps) , with 2000replicated actor spawned which represent fireball functionality. FIreball has around 50 functions, 10 floats and 10-20 bools
editor memory usage go from 1.2gb to 1.4gb

but with tick DISABLED

I’ve answered this in a couple other places but Actors take up nearly 1KB while Objects take up about 56 bytes. That’s a pretty big difference. It doesn’t make sense for me to use Actors to represent an item slot for an inventory system. Not even for the inventory container itself, Object would be much better suited just on the data used alone. But really. If you want to optimize it properly using a struct may help. Even better if you can do this in c++ and be careful about your data usage. Only use the functionality you need from ue4, and avoid all the rest. If you need to optimize that’s the approach necessary. If your game is small scale then it doesn’t matter though.

1 Like