Distance between two elements

Get help using Construct 2

Post » 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

Post » 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

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Feb 20, 2013 6:09 am

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


Return to How do I....?

Who is online

Users browsing this forum: SpartCrafter and 20 guests