select specific actor from a group of random ators


  • Posts: 6
greetings fellow stencylers;
i have this behavior the choose a random actor and spawn it .........
everything is working perfect but my question is , how can i make a bunch of those actors get spawned more often than the rest of the other actors?
keeping in mind i want to keep the spawning process randomized
what i mean is
lets say that there are 35 actors
so the possibility of each actor to be spawned is 1/35 so i want to increase the possibility of some of those actors to be spawned more often.
i thought of creating more (actor type attribute) what i mean is that i was thinking of attaching the actors i want to spawn more often to more than one (actor type attribute)
i hope i made myself clear.
your response is highly appreciated
thank you in advance for your attention and time.     


  • Posts: 2262
I did something very similar on a recent project. I just increased the number of conditions that spawned a particular actor. Eg if Y = 1,2 or 3 spawn actor 1.


  • Posts: 81
What I would do is create a map of the actor names, and assign them a number.   Create an actortype attribute.  Create a number attribute (call it"PoolNumber" as an example).  Set PoolNumber  to a random integer between 1 and 6 for example.  Do an "if", "otherwise if"  string of blocks...  These will be pools for different odds on generating an actor.  So if PoolNumber =< 2, you'll then have another random number decide which actor to pick that has a 1/3 chance of spawning. "otherwise If PoolNumber = 6", pick an actor that has a 1/6th chance of spawning.  Just make sure your map has actors of different odds numbered in order or their odds so that the random integer is between x and y in the map.  Hope any of that makes sense.  Here's sort of an example of something similar I did where my actor names are just numbers (I didnt use a map):


  • Posts: 6
first of all
#JeffreyDriver and #wahmpire thank you for taking the time to check the post and reply i really appreciate it.
if i wanna keep it simple i will go with #JeffreyDriver.
at the end  occam razor said that "the simplest solution is always right"

so basically #wahmpire to get this straight what you did is you divided your actors into two groups and narrowed the random number fro 1-6 to 1-2 and 3-6 thus increasing the chance of each actor.
(am asking because i don't want to apply the behavior without understanding  it)

that was really helpful guys .
hoping that one day i will be able to help you back

thank you.


  • Posts: 733
Crazy how complicated things can get when you have to deal with random numbers.


  • Posts: 81
No problem Peetsha!  Yes, I wouldn't do it the way I did it exactly because I had certain reasons for it in my game.  I'd use a map of the actor names instead, and number them 1-35 for their values.  Then for example, say actors 1-6 randomly generate when their pool number randomly generates, and maybe 7-20 randomly generate for another pool number, etc so that you have groups divided up by odds.  Won't blame you for going a simpler way :)  Basically randomly generating for a pool, then randomly generating an actor number inside of that pool.


  • Posts: 6
Thanks wahmpire for taking the time to explain..... I really appreciate it.... And it's guys like you who give the new stencylers(If I may say