Spawn Actor at random and Percentage

feromanferoman Member, PRO Posts: 130
edited August 2012 in Working with GS (Mac)
I open a discussion:

For Spawn actor on a ground.
The objects should appear under certain condition, and randomly.
You may say it's easy, Ok this is easy.

BUT

requires only one object should appear as a percentage of probability.

I press a button, 1/10 object (for example) should appear, but
which?
spawn actor according to a percentage probability:
- 1 tomato, a chance to "Spawn" to '45%.
- A bag, a chance to "Spawn" at 25%.
- A pencil, a chance to "Spawn" to '20%.
- A diamond, a chance to "Spawn" to '10%.

So how do we code this???

I await your comment

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @feroman

    Hi, firstly, to clarify: when you say you want a percentage of the actor to appear, do you mean it's transparency? Or do you mean literally only a percentage of the actual image to appear?

    If it's the 2nd one, you'll need to make masks (presumably from 5% to 95% coverage, in 5% increments). The only other way is a lot more work: make each of your objects in pieces...

    Hope that's guided you in the right direction.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • feromanferoman Member, PRO Posts: 130
    @gyroscope
    to be more precise,
    in the game, I dig the earth with a pickaxe to find objects.

    At each place dug, an object appears randomly.

    so, it is necessary to call the behavior "spawn actor", with random actors.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012

    D'oh, silly me; I see what you mean now...

    OK, one way would be as follows:

    Change Attribute SpawnActor to random(1,100)

    When SpawnActor >0 and < 46
    Spawn Tomato

    When SpawnActor >45 and < 71
    Spawn Bag

    When SpawnActor >70 and < 91
    Spawn Pencil

    When SpawnActor >90 and < 101
    Spawn Diamond

    Hope that sort it now for you. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • feromanferoman Member, PRO Posts: 130
    thanks it’s work
Sign In or Register to comment.