How do I pick instances without families?

Get help using Construct 2

Post » Fri Mar 18, 2016 7:56 pm

With multiple instances of an object, how would I set up conditions to pick two that for example are overlapping (or the same angle), if I didn't have access to families?

ObjectA is overlapping ObjectA seems to always run, I guess as each instance is always overlapping itself.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,623
Reputation: 62,667

Post » Fri Mar 18, 2016 8:46 pm

I think after an overlap condition like that you use pick nth instance to pick one or the other. An instance won't overlap itself, you can test this by setting it's opacity to 50 or something to visualize it.

Another approach I've used is to have a seperate detector object, which you can set to the position of one object and then detect the other ones.

For comparing angles and such you can pick one instance, save it's iid to a variable then pick all and do the comparison from there.

Or you can just follow a pattern like this:
Code: Select all
+---------------------------------------------------------------------+
| for "a" from 0 to sprite.count-1                                    |
| for "b" from loopindex+1 to sprite.count-1                          |
| compare sprite(loopindex("a")).angle = sprite(loopindex("b")).angle |
+---------------------------------------------------------------------+
   +------------------------------------------------------------------+
   | pick sprite instance loopindex("a")                              |
   +------------------------------------------------------------------+
   +------------------------------------------------------------------+
   | pick sprite instance loopindex("b")                              |
   +------------------------------------------------------------------+
Or some simplification to that effect.

There are other ways too, and basically it involves picking one, and saving values to variables then picking the other.
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Fri Mar 18, 2016 9:43 pm

Thanks R0J0, saving relevant information to local variables and repicking worked well.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,623
Reputation: 62,667


Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, kiki4construct, Username05 and 33 guests