spawn actor from class bp and c++

i use this for spawning npcs but when i do this with large amount

it makes lags even in c++

how can i fix this issue?

if its just on startup hide it behind a loadscreen, if not maybe try spread it across frames (ie use multiple small loops)

I think this might be a case for using the object pool pattern. This pattern is used to have all the objects loaded on game start and you will only make them visible/interactable at runtime. But the memory is beeing reserved so it will reduce lags.

There is a great video tutorial on this by Ali Elzohery

Having the pool as a component like in the tutorial might not be the best for your case, so maybe you want to make it an actor. I changed it later on and had a lot of work with it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.