random spawn actors with an exception

tabelortabelor Member Posts: 114
edited November -1 in Working with GS (Mac)
Hi all, i would like to use the random function to spawn random actors, the numbers would be from 1 to 10 (min 1, max 10) but i don't want to spawn number 5, so from one to ten except number 5, is this posible???? How can i do this?

Comments

  • ChaserChaser Member Posts: 1,453
    Set up (1,4) and in another spawner set up (6,10). Otherwise I'm not sure if you can exclude a number in between
  • tabelortabelor Member Posts: 114
    i understand your solution, but is not viable for my needs.
    I explain my case: i have for actors which spawns randomly in my game, and everytime i kill one my game spawn an actor (randomly) but with an exception of the last killed actor, so it is a random spawning but i don't want to spawn the last killed actor, wich could be anyone from 1 to 4... I know how to do this in code programing but i don't know how to do it in GS
  • AppsRacKAppsRacK Member Posts: 346
    Well i've ask it here recently in the forum but nobody answer but i manage to find a way to do this but im really sure its not the most oprimized way.

    1. dont use spawn make one actor and add a self attribute like selfID and set it to integer and another attribute name it "randomizer" and set it to integer as well.

    2. place 10 actors in the scene and change each selfID value from 1-10

    3. now using the self.selfID attribute of your actor you can use interpolate or change attribute to move them in your scene (depends on how your game works).

    4. make a global attribute "killMonsterID" and set it to integer.

    5. make a rule in your actor like this.
    >>if collide with bullet & selfID = 1
    change attribute killMonsterID = 1
    6. now on your spawning(or moving) rule on your actor do this.
    >>change attribute randomizer = random (1,10)
    >>if randomizer = killMonsterID
    then >> change attribute randomizer = random(1,10)

    Thats how i did mine on one of my project but i did hold for a while coz having 80+ actors (with rules) in the screen is not healthy for GS even when you dont have any physics. Some rules skipped even in iPhone4. Sorry if its a bit cloudy i dont have any mac here in the office :)
Sign In or Register to comment.