distance to (mouse-pointer / Sprite) — Scratch Block Guide
Returns the straight-line pixel distance between this sprite’s center and the target.
What this block does
Returns the straight-line pixel distance between this sprite’s center and the target.
Trigger enemy aggro when within 120 pixels or calculate circular hit detection.
- Category: Sensing Blocks
- Key tip: Much faster than pixel-perfect collision for circular objects like planets or explosions.
Working Scratch example
Try building this small script in the Scratch editor, predict what will happen, then click the green flag to test it.
- When green flag clicked
- Forever
- If <(distance to Player) (120) then
- Point towards Player
- Move 3 steps
Try it: Enemy wakes up and chases the player when they get close.
Related block guides
Explore other blocks in the same category or return to the full English Block Dictionary.
FAQ
When should I use "distance to (mouse-pointer / Sprite)" in Scratch?
Trigger enemy aggro when within 120 pixels or calculate circular hit detection. Much faster than pixel-perfect collision for circular objects like planets or explosions.
This guide is provided for educational purposes. Scratch screens and terms may change over time, so please check the official Scratch website as well.