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

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • Add event>System>Pick Instances>Pick nth

  • 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).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad to hear it. Happy coding!^^

  • 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?

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