Discuss Scratch

BluePiano2012
Scratcher
0 posts

how to show the distance between two objects (eg. mouse from player)

I'm making a golf template and need a way to use the distance of the mouse from the ball as a variable of how powerful the shot will be
Dragonmyflesh
Scratcher
500+ posts

how to show the distance between two objects (eg. mouse from player)

https://en.scratch-wiki.info/wiki/Distance_to_()_(block)

Go to the workaround section and copy it.

Last edited by Dragonmyflesh (July 30, 2024 04:06:37)

RokCoder
Scratcher
1000+ posts

how to show the distance between two objects (eg. mouse from player)

@Dragonmyflesh offers a solid solution that is useful in many situations - d=√[(x2-x1)²+(y2-y1)²]

However, for the distance from a sprite to the mouse pointer you can simply use the build in distance block -

distancetomouse-pointer

Powered by DjangoBB