Choose random family object only once

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello!

    I'm currently building an "Interceptor" style game where objects are randomly spawned from one of two families and drop down from the top. Upon the user hitting these spawned objects, they blow up and accumulate point values.

    My problem is, I want each object from both families to only spawn once. I need some way to set an instance variable on the individual objects in the family once they're chosen and spawned so as the next time the game goes to pick a random instance from either family, they won't choose objects that have already been used (chosen).

    Does anyone have insight as to how to accomplish this?

    Any help/advice is greatly appreciated!

    Thanks,

    HG

  • If you don't want to use the object again after blowing up, u can destroy on collision!

  • hgstudio

    here's a solution, only from one family, but its a start :)

    creating unique random object from family

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • vtrix

    Thanks so much for the reply and the capx!

    I think I'm failing to see how this addresses my issue however. For this to function in the manner that I'm looking for, hitting the "create" button would only yield a single instance of each object in the family. Once all 6 objects have been created once, it would no longer generate anything.

    Does that make sense?

    Thanks in advance for any further insight.

    Nate

  • hgstudio

    the example generates a random object from the family but checks if its not the previous one

    your probably looking for something like a string or array with the objects name in and once created remove it from that list, there should be some examples for it in forum, no time right now for example

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