Spawning random object at certain %

l2gstarl2gstar Member Posts: 19
Hello again,

So I have situation here where I have no idea how to make things work.
I want to spawn a random object on certain % when pressed.
So I have few different objects.
When I click on actor I want that one of those objects would spawn randomly at my given percentage.
I want that 1 object would spawn let's say at 5% chance and other object at 25% chance.
How do I do that?

Please help!

Comments

  • BoomshackBarryBoomshackBarry Member Posts: 712
    edited June 2013
    When you click on the actor you can set an attribute to a random number between 1 and 100. Then if you want to spawn actor A 5 percent of the time and actor B 25 percent of the time, have a rule that says:

    if the attribute <=5 then spawn actor A.

    if the attribute >5 and <=30 then spawn actor B.

    etc.
  • DeadlySeriousMediaDeadlySeriousMedia ArizonaMember Posts: 838
    Have an integer attribute called "Dice" in the clickable actor.

    Have a rule that says:

    When touch is pressed
    change "Dice" to random(1,20) [use the expression editor for this]

    A second rule that says:

    If "Dice" = 1
    spawn actor


    This would be for a 5% chance. For 25% use 'random(1,4)'

    I think my math is right here.
  • l2gstarl2gstar Member Posts: 19
    Can someone please make quick example on gamesalad and upload it here because at the moment am confused, thanks!
  • BoomshackBarryBoomshackBarry Member Posts: 712
    edited June 2013
    I don't mean to sound mean at all but it's fairly simple logic really. I see that you're new here so if it's causing difficulty it might be a good idea for you to take a look through as many tutorials and cookbook examples as you can, to get to grips with GS creator. Soon when you're familiar with everything that GS can do problems like this will be easy for you to overcome by yourself.
  • l2gstarl2gstar Member Posts: 19
    Yes I am new, I checked some tutorials but I can't find anything like this:(
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Heres a file I made really quickly.
    If you open the Round Rules actor, you'll see the change attribute which change the game attribute to random(1,4) - What this is doing is changing that attribute to either 1, 2, 3 or 4. Based upon that attribute, we can spawn different actors.
  • l2gstarl2gstar Member Posts: 19
    Heres a file I made really quickly.
    If you open the Round Rules actor, you'll see the change attribute which change the game attribute to random(1,4) - What this is doing is changing that attribute to either 1, 2, 3 or 4. Based upon that attribute, we can spawn different actors.
    Big thanks, I will try to attach this info to my work, thank you again!
  • BoomshackBarryBoomshackBarry Member Posts: 712
    edited June 2013
    Okay I had a few minutes spare so I've made a quick example project for you, I'm not sure how to add files on forum posts like I've seen some people do so here's a dropbox link to it!

    https://dl.dropboxusercontent.com/u/72942216/randomSpawn.zip

    edit: looks like Braydon beat me! PS @Braydon_SFX how do we add files like that?
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    @BoomshackBarry - You have to be a PRO user to have those powers. ;)
  • BoomshackBarryBoomshackBarry Member Posts: 712
    @Braydon_SFX ah I see thanks. Just as well I'm planning to go pro soon :)
Sign In or Register to comment.