Choose random family object only once

Get help using Construct 2

Post » Tue Nov 12, 2013 11:10 pm

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
B
5
S
2
Posts: 7
Reputation: 578

Post » Wed Nov 13, 2013 11:00 am

If you don't want to use the object again after blowing up, u can destroy on collision!
B
15
S
4
Posts: 138
Reputation: 2,003

Post » Wed Nov 13, 2013 12:48 pm

@hgstudio

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

creating unique random object from family
ImageImage
B
71
S
22
G
7
Posts: 827
Reputation: 10,177

Post » Wed Nov 13, 2013 4:04 pm

@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
B
5
S
2
Posts: 7
Reputation: 578

Post » Wed Nov 13, 2013 8:49 pm

@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
ImageImage
B
71
S
22
G
7
Posts: 827
Reputation: 10,177


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 11 guests