How do I measure the distance between objects?

Get help using Construct 2

Post » Sun Dec 11, 2016 7:49 pm

Helllo,
for an AI I'd like to make the Enemy move when the Player is Close enough. But I don't know how to measure distance :( The AI should react when the Player is near enought and move towards and attack.

Thank you for your help. :)
B
3
Posts: 2
Reputation: 179

Post » Sun Dec 11, 2016 8:01 pm

You can use this formula

distance(object1.x,object1.y,object2.x,object2.y)

That returns the distance between object1 and object2 which you of course change to the name of the objects in your game :)

But you can use line of sight behaviour or a "is overlapping at offset" condition to see if the player is in distance as well. It is easier and might be better.
B
55
S
24
G
13
Posts: 767
Reputation: 12,575

Post » Mon Dec 12, 2016 6:02 am

Thank You!
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: 25games and 18 guests