# Distance between two elements

Get help using Construct 2

### » Wed Feb 20, 2013 5:37 am

Hello

I have 4 values

playerX = Where the player is on X
playerY = Where the player is on Y
Touch.X = Where the player is about to move to on X
Touch.Y = Where the player is about to move to on Y

I need to make a comparison... I need to know if the distance between playerX and Touch.X is greater than playerY and Touch.Y

Is there an easy way to calculate and compare these?

Thanks
B
5
Posts: 17
Reputation: 459

### » Wed Feb 20, 2013 5:52 am

System condition Compare two values

[code]Compare two values
First field: abs(Player.X - Touch.X)
Operator : Greater than
Second field: abs(Player.Y - Touch.Y)[/code]
(depending on the results, you might want to invert player and touch in the operation)

abs() is a system expression that will return a positive number.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
304
S
123
G
98
Posts: 7,357
Reputation: 72,958

### » Wed Feb 20, 2013 6:09 am

That worked perfectly, thanks!
B
5
Posts: 17
Reputation: 459