Random spawning between several different character models?

I never looked into “Random” before, I’d usually always have enemies laid out beforehand.

I’m in the middle of making a game where many enemies swarm you at once, and am going to make several different models to be the enemies.
Planning on spawning enemies via an empty, (I have another question regarding spawning, but I think I’ll leave that to a later date. I may be able to figure it out on my own.) so how can I ensure the models are different each time?

I don’t care much if they spawn the same model two times in a row,

So how can I make enemies spawn randomly through empties?


Three operations:
A) add a character to a given numerical key e.g. 1-> small soldier, 2-> big fat chef

B) generate a random number

C) Connect B) with A) and you get what you want.

A) should not be a big deal for you. If it is, let us know.
B) you can use the random actuator, it places a random value in a property of your choice each time you activate it. You can play around with it. Debug properties, or font ibjects are your friends. If you have questions, do not hesitate to ask.
C) no big deal either. Just ensure you do B) before A). It does not matter how much time between the operations is.

I actually NEVER noticed the Random Actuator before, only the sensor.

What is the difference between the two, and must I use the “Add Object” brick, as it asks for what specific object to spawn?

The difference is the typical differences between sensors and actuators.

A sensor evaluates the scene status (it senses) and triggers connected controllers. The random sensor as the name suggests randomly evaluates positive and not positive plus the according triggers. As this is binary output there is not really much to configure.

An actuator changes the scene status when active (it does something). The random actuator generates a random number and places the result in a property similar to the Property actuator. The random actuator is auto-deactvates after one frame, so you need to activate it again, to create a new random number. It can create several number types with several generation methods (see GUI). I think you want to use the int uniform mode.

I suggest you use one add object actuator for each enemy type. Alternatively you can use a single one and reconfigure it via Python, or you add the enemy via Python without the actuator. Either way is fine. The principles are the same property value -> add enemy type for this value.

Does this help?

always--------and----------Random (property =uniform int)
if Property=1------and -message to spawn 1 “spawn bob”
if Property=2------and -message to spawn 1 “spawn kyle”
if Property= 3-------and-----message to spawn 2 “spawn bob”

and so on and so forth?


Made this pretty quick (following both your advice) cause I gotta take off in a little bit,
I’ve got properties on most objects, most bricks I’m sure aren’t doing anything… it’s a mess.

For the most part, it works!
But on SOME occasions, it won’t spawn anything (a 4th possible object?! If so it was unintentional)
Another problem I’ve come across is THEY SPAWN IN BOATLOADS, turning on Tap makes them not appear at all.

Check it

I also added the booleen so it would no add 2 on frame 1

Zombie Zero (lol) is your issue with not spawning 1,

and you need true pulse mode, and tap


RandomSpawnBPReturn.blend (469 KB)

Gee, thanks a bunch!! :]

Zombie Zero (lol) is your issue with not spawning 1

Ah, of course. Amateur mistake on my part.

Once again you’ve saved me,
thank you both for the help!

There are no silly questions, what I was laughing about was patient zero==Zombie Zero