Download

Simulation type game spawn peons advice...

HI!

Looking for advice. I’ve got a simulation type game (think Banished) that I’m working on (very early stages), with basically 1 level (just one big map). So I’m questioning what the best practice is for the following:

At the beginning of the level I will have 10 or so peons spawn. Throughout the duration of the game I will have the number of peons grow (based on certain factors I determine). I believe I will keep all of these peons in an array. So here’s the question, where would be the best place to actually SPAWN these peons? I originally thought that I would just use the Level Blueprint to spawn 10 peons and store the array there. However, I’ve read so much that people try and stay away from using the Level Blueprint and just make everything in custom BP’s so now I’m doubting myself. Does any one have any advice on this?

The hardest thing for me to wrap my head around is where and when to use Level Blueprints, Game mode, and other default BPs that are set up when you begin a level in UE4 as opposed to just creating custom BPs.

Thanks so much!

For your case, there isn’t a right or wrong. If I were you, I’d just handle it in the level blueprint. A reason that you might want to use a custom blueprint instead is if you want this to be dynamic throughout various levels, rather than having the functionality stuck inside of the one level blueprint.

Yeah the usual reason for keeping things in blueprint actors etc is so that you can re-use them in other projects or other levels without the code being tied specifically to that level. If you are intending to only have 1 level and never any more then it’s fine to work in there, just be aware its not easy to transplant into something else and you can make it a child of another actor or parent to another.

It’s depends on your project where to spawn them…
You need to create custom BP classes for their behavior this is best way and then if you want to save them after quit game you can save their grows up in files but if you don’t need u can skip saving.
for spawning them again it’s depend on project you have many options.
simplest way is Level Blueprint but i prefer GameInstance for more complex case…

Do not use level blueprint. Instead create interface and add it to those peon pawns.
Then create AI blueprint, keep your all functionality there. Assign that AI blueprint as ai for those pawns.
No more need of level blueprint, or casting from player controller or anything like that.

In that AI blueprint you do not need to use any of advanced techniques, you can think (for now) that it is your private level blueprint for just pawns.
Casting to AI and asking it for directions is even easier than getting info from level BP. telling orders from AI to pawns can be done trough that interface (until you learn and use proper but more advanced AI tools).

And biggest benefit of it all: you will have all that functionality in blueprints ready to be translated into behavior trees later.

Oh great. Thanks a lot for the advice guys, I appreciate it!

Actually, while I’m looking through this, just to clarify. When you say create AI blueprint, do you mean an AI Controller BP? Thanks!