Do action if within distance (issue)

Get help using Construct 2

Post » Fri Nov 02, 2012 9:38 pm

I have an object that moves towards the player if it gets within a distance of 500 pixels of eachother. However, I have 3 of these objects on the same map.

Only the one that I last placed on the map will be used to detect the distance. Once I get close to it, all 3 of the objects come towards me. But if I get close to the other 2, nothing happens.

What can I do to make them all separate? If you know what I mean
B
3
Posts: 9
Reputation: 643

Post » Fri Nov 02, 2012 9:50 pm

Pin an invisible to sprite to each one, and have a different event for each one that tells it to move towards player when it touches another one of the objects.

(eg)
-Object1range on collision with Object2
-> Set angle towards player

-Object2range on collision with Object3
-> Set angle towards player

-Object3range on collision with Object1
-> Set angle towards player
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Fri Nov 02, 2012 10:44 pm

Nope, 'for each' is all you need.

+For each object
+compare two values: is distance(player.x,player.y,object.x,object.y)
    -> actions
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Nov 02, 2012 11:40 pm

[QUOTE=keepee] Nope, 'for each' is all you need.

+For each object
+compare two values: is distance(player.x,player.y,object.x,object.y)
    -> actions[/QUOTE]

This works, thank you very much!
B
3
Posts: 9
Reputation: 643


Return to How do I....?

Who is online

Users browsing this forum: Magistross, zatyka and 24 guests