random object selection

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I am looking for my game to randomly select 3 out of 20 objects and display them on the screen. Then I would like the three objects to randomly rotate on the screen after about five seconds. what is the best way at going about this. I have tried system->on start of layout-> set layer random(0,19) three times, but what i run into is the system will sometimes randomly select the same layer twice, or even three times. is there a better way?

  • Are they all different objects, or is it 20 instances of the same object?

    If its all the same object you can do a loop, or repeat 3 times using pick a random instance under sprite actions. However that may pick the same instance more than once. To get around that you'll have to compare a private variable, but on the bright side you can use that variable to tell the system that that particular sprite was picked.

    There's a function object you can use for the off chance one instance gets picked more than once... third party.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i recommend that you make 20 instances of the same object. then you can use "objectcount" to create a loop. if objectcount returns less than 3, repeat random picking. if objectcount returns three, stop.

  • Hello,

    Thanks for your feedback!! I actually want to use twenty different objects. Any suggestions for that?

    Thanks in advance

  • Just use the same object and put the image representing them in different animation frame.

    On start of frame set the frame to whatever you want

    and don't forget to set the animation speed to 0. You can access it in the property panel when you are in edit mode.

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