How do I Run Action Based on Locations of Multiple Instances

0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hey guys! So I'm trying to get an action to run IF multiple instances of the same object are in specified positions. This works perfectly fine with an object with a single instance, but doesn't seem to work if multiple instances are introduced. For example, let's say I want to create an object IF any instances of (X)(Doesn't matter which instance, just that there are multiple) object are in either position of (X=200, Y=200) and (X=100, Y=100).

    This means that for the action to run, I have to have instances of (X) object at both positions, not simply one or the other. However, it doesn't matter which instance is in which position, just that an instance occupies those positions.

    If I do something simple like this, it works perfectly fine, albeit only for one instance of one object

    However, if I do something like this, it doesn't work. It doesn't appear that multiple instances are being read through. Its conditions are met only if that one object instance is in two places at the same time, which is impossible.

    Is there a way to say "If any instance of x object is at x position AND at x position, then..."?

    As always, thanks for the help and consideration

  • The second option doesn't work, because first you are reducing the tiles referenced to tiles that are at 200, 200 and then you are saying these tiles should also be at 100,100..

    It's impossible for tiles to be at two places at once, so the conditions will always be false and the actions will never run..

    what would work (just one example, for there are more ways:

    Tile x = 200

    Tile y = 200

    (subevent)

    -- system pick all tiles

    -- Tile x = 100

    -- Tile y = 100

    System create object Tile

    This way only if there is a tile at 200,200 the subevent will run

    Because subevents normally only pick tiles from the tiles referenced in the events above, the condition "pick all tiles" tells C2 to check all instances..

    If one of all instances is at 100,100 the condition is true and the actions will be executed..

    I would add a system trigger once condition, for else this event will run every tick and endless amounts of tiles will be created..

    There must actually be a much better way to achieve the actions you are trying to perform, but if you want to do it this way, the above explanation should get you there..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your solution definitely works. I tried numerous ways to get it to work (ultimately resulting in bitter defeat), but this should work just fine for what I need. Thank you!

  • I hope you also understand my explanation for why my event works and your event doesn't..

    It will help a lot when programming with C2..

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