How do I Measure Distance between two objects?

Just started using Construct 2? Post your questions here

Post » Fri Oct 17, 2014 6:53 pm

Hello, im trying to include an event where if a prisoner is to far away from a guard he will change color to notify the player but im lost at how to do it.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 1
Reputation: 177

Post » Fri Oct 17, 2014 7:39 pm

to get the distance you'd use:

distance(Player.X,Player.Y,Guard.X,Guard.Y)

so then you could do:

Compare:
distance(Player.X,Player.Y,Guard.X,Guard.Y)
>=
100 (distance from guard in pixels)
Do action.
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Mon Sep 28, 2015 1:30 pm

What am I dong wrong here, it's not printing anything?
http://prntscr.com/8leqwr
B
13
S
5
G
2
Posts: 8
Reputation: 2,471

Post » Mon Sep 28, 2015 2:28 pm

If I'm not totally wrong you compare your variable measure with the distance, you don't set it.
That what look like.
Code: Select all
System Every tick -> set measure to distance(Player.X,Player.Y,Guard.X,Guard.Y)
                     set text to "Distance: "& measure
B
24
S
3
G
1
Posts: 451
Reputation: 2,165


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests