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
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

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
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Fri Mar 18, 2016 9:43 pm

Thanks R0J0, saving relevant information to local variables and repicking worked well.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303


Return to How do I....?

Who is online

Users browsing this forum: duke2704, RetrocadeMedia, sebrosen, Yahoo [Bot] and 32 guests