actors spawning on one of three positions, randomized?
Zompar
Member, PRO Posts: 6
Hi, I am working on a remake of orc attack (you have to defend a castle by throwing rocks down onto orcs who climb the walls on ladders). my problem: i have three ladders standing on the castle wall and need my orcs to spawn randomly on these three ladders. the positions of the ladders are fixed (ladder 1 at x=150, ladder 2 at x=390, ladder 3 at x= 650)
(i already found a link to a random time spawner here in the forums which will surely help me to spawn the orcs in randomized time intervals. now i need to find a solution for the randomized spwan position). thanks in advance!
Comments
Just use three rules. Either pick a random number in the spawner and spawn in position 1 if random = 1, position 2 if random = 2 etc., or have the actor pick a random number when spawned, move to the position and then become visible.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Create a index self attribute in the orc character and call it random_X. Add a change attribute behavior in the orcs actor that reads (Change self-random_X to random 1,3).
Then create three rules inside of the actor. The first should read (If self-random_X =1) change actors self-position-x to 150. The second should read (If self-random_X =2) change actors self-position-x to 390, and the third should read (If self-random_X =3) change actors self-position-x to 650.
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
Here is another fun way:
Change Attribute: orcPosition To: random(1,3)
Cange Attribute: self.Position.X To: (self.orcPosition==1)and(150)or((self.orcPosition ==2)and(390)or(self.orcPosition==3)and(650))
Great, thanks a lot guys for the quick and detailed Replies!!
Nice and simple! Here's another simple way:
@Zompar -- you are welcome.
@Socks -- clever!