pick random object

This forum is currently in read-only mode.
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • hi,

    I've searched in the forum (and found a similar topic, about creating private variables (in the pick random object-topic), but got lost while reading the topic) and wiki, but couldn't find the answer to:

    does the event "pick random object" work with a tetris clone, so that Construct chooses from a set of (edit: already existing) pieces, randomly?

    If so, that is what I'm searching for.

    (Perhaps the real question:)

    But when selecting "pick random object", I only get to choose 1 object. So how can it select randomly, from only 1 object? I would like to have a random choise between multiple pieces.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i believe 'pick random object' is used more for existing objects, not for picking objects to spawn from a group of non-existing objects.

    what you could do to pick a random piece --

    condition for spawning new piece

    -set private variable to Random(7) (replace 7 with however many possible pieces there are)

    if private variable = 1

    trigger once while true

    -spawn piece 1

    if private variable = 2

    trigger once while true

    -spawn piece 2

    and so on

    [quote:2iz066v7](Perhaps the real question:)

    But when selecting "pick random object", I only get to choose 1 object. So how can it select randomly, from only 1 object? I would like to have a random choise between multiple pieces.

    well, for future reference for other applications, you would add all the pieces to a family and then pick random object from that family. but again, pick random object wouldn't really work for this situation, i don't think.

  • Thanks, I will try to get it work.

    I have about 5 sprite-tetris-blocks which I will try to show randomly with your information.

  • oh, and i'm not sure why i said private variable. it would probably be smarter to use a global variable.

  • They just added this condition to families, why don't you try that?

    Just add all the different objects to the same family.

  • They just added this condition to families, why don't you try that?

    Just add all the different objects to the same family.

    Thanks for the tip, I'm using the family object, which contains the objects I want to choose from.

    Family is useful.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)