Check the distance between multiple Instances?

Get help using Construct 2

Post » Fri Sep 06, 2013 11:32 am

Hi,

I got it working with 2 instances, but for more i get stuck.

The aim is, if X instances of an object are nearby EACH other these should all perform an action once, and switch back when they are out of the range to each other.

Any help welcome :)

PS: Guess I could make it if I would know how to override the loopindex inside a for-Loop, or a command like "nextLoop".xeed2013-09-06 11:37:43
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Fri Sep 06, 2013 2:10 pm

+ local variable X = Object (First Instance)
+ local variable Y = Object (First Instance)
for each ordered by distance(X, Y, Object.X, Object.X)
if (distance(..) == 0)
set X = Object
set Y = Object
perform action
else
stop loop

If you have any question aks me, it works fine for me
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Tue Sep 10, 2013 8:04 am

yes, would you like to give me a screenshot of your event?

I am not sure how you check the distance between all instances here.

for each ordered by distance(X, Y, Object.X, Object.Y)

just checks from the first instance, not all instances to each other.

also only the first nearest instance is picked. If you leave the loop there, maximum 2 instances can do an action.

many thanks for additional information!xeed2013-09-10 09:33:07
B
15
S
3
G
5
Posts: 396
Reputation: 4,977


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, jatoblendy and 51 guests