How do I Run Action Based on Locations of Multiple Instances

Get help using Construct 2

Post » Tue Jun 02, 2015 3:54 am

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

Image

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.

Image

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 :D
B
9
S
2
Posts: 34
Reputation: 679

Post » Tue Jun 02, 2015 8:42 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jun 02, 2015 9:08 am

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!
B
9
S
2
Posts: 34
Reputation: 679

Post » Tue Jun 02, 2015 9:26 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 10 guests