Discuss Scratch
- Nambaseking01
-
1000+ posts
Distance to (x) (y)
Agreed, the workaround is too long and this could be way easier for New Scratchers. This could also be useful for adventure games, to show how much pixels there is left to reach the destination.
- sportfan999
-
1000+ posts
Distance to (x) (y)
Here's a simple workaround:
set [y change v] to ([abs v] of ((y position)-(desired y::grey)))It uses the good ol' y=mx+b, but because the y-intercept isn't important, we just find the slope.
set [x change v] to ([abs v] of((x position)-(desired x::grey)))
set [distance v] to ((x change)/(y change))
Please say Supportwhy. This is the discussion forums, not a ballot box.
Last edited by sportfan999 (Nov. 30, 2020 21:42:32)
- portalpower
-
1000+ posts
Distance to (x) (y)
you forgot to add abs, it can't be a negative number Here's a simple workaround:set [y change v] to ((y position)-(desired y::grey))It uses the good ol' y=mx+b, but because the y-intercept isn't important, we just find the slope.
set [x change v] to ((x position)-(desired x::grey))
set [distance v] to ((x change)/(y change))Please say Supportwhy. This is the discussion forums, not a ballot box.
- sportfan999
-
1000+ posts
Distance to (x) (y)
True. Just a sec.you forgot to add abs, it can't be a negative number snip
- Randox
-
1 post
Distance to (x) (y)
Oh good it's just a simple Pythagorean theorem. “A^2 + B^2 = C^2” and all that… Well mostly. Still doable
- wvj
-
1000+ posts
Distance to (x) (y)
Workaroundable but support because it makes things easier

- BanMeOS
-
500+ posts
Distance to (x) (y)
Workaroundable but support because it makes things easier
yeah, that one is just the distance formula from math which is just sqrt((a1 - a2)^2 + (b1-b2)^2). This comes from the pythagorean theorem.
- medians
-
1000+ posts
Distance to (x) (y)
Bringing this topic up. You could use the distance formula though.
Also, there could be as well:
Also, there could be as well:
distance between x: () y: () and x: () y: () ::sensing reporterYou would be able to replicate this by putting x position and y position as one of the inputs.