How do I filter two instances of the same object type?

Get help using Construct 2

Post » Mon Mar 21, 2016 6:14 pm

Apologies if the title doesn't make it very clear what I'm trying to do. I haven't been able to find an answer to this question anywhere in the forums or the manual, and no doubt part of the reason is because I can't figure out how to phrase exactly what I'm trying to do. I'm sure it's possible though.

Basically I have lots of instance of a physics object (let's call it PhysicsLine), which is in the shape of a line. I already have it set up so that some instances of PhysicsLine are connected together by limited revolute joints, to create what looks and acts like a chain of lines, or like a string. On screen there can be multiple such 'chains' or 'strings' which are not connected to each other. As part of acheiving this I have an instance variable in PhysicsLine called 'LineSection'. Every instance of PhysicsLine which make up one 'chain' or 'string' shares the same value in 'LineSection', and only instances of PhysicsLine which share the same value in their 'LineSection' instance variable end up connected to each other.

What I want to do is tell the game to disable physics collisions between all instances of PhysicsLine which share the same value in their 'LineSection' instance variable. But I can't seem to figure out how to get it to select, say, only the instances for which LineSection = 1, and then in the action 'Disable Physics Collisions with PhysicsLine' have it also know to only select instances of PhysicsLine for whic LineSection = 1.

This is a problem I'm having in this particular scenario, but it's a more general problem I've often run into. Is there a general trick I'm missing to getting Construct2 to filter an object type down to a select few instances, and then have those instances interact with another filtered down group of the same object type?

Anybody's help would be very, very much appreciated! I feel like my ability to program lots of things would be vastly improved if I knew how to do this.
B
6
Posts: 14
Reputation: 380

Post » Mon Mar 21, 2016 6:49 pm

Add event>System>Pick Instances>Pick nth
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

Post » Tue Mar 22, 2016 7:12 pm

Thanks for the push in the right direction bloodshot! Searching for how to use the 'pick nth instance' has led me down a trail of discovery (even if your reply didn't on its own solve my problem).
B
6
Posts: 14
Reputation: 380

Post » Tue Mar 22, 2016 7:43 pm

Glad to hear it. Happy coding!^^
B
15
S
7
G
34
Posts: 55
Reputation: 18,478

Post » Tue Mar 22, 2016 7:56 pm

So basically, you want to have a single object have physics disabled for some instances of the same object, but not others.

I think you'll either need custom physics events or sperate objects for each chain of lines.

How many chains do you need at any given time?
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, guannstar, marcinkowski, Shenkai the ssj, Yahoo [Bot] and 12 guests