<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[The &quot;Distance to (object)&quot; Block]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="prerequisite"></a>Prerequisite</h2>
<ul>
<li><a href="/topic/73/working-with-blocks">Working with Blocks</a></li>
</ul>
<p dir="auto"> </p>
<h2><a class="anchor-offset" name="description"></a>Description</h2>
<p dir="auto">The “Distance to (object)” block is a reporter block in the sensing category.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c5aa99df-ac30-4229-a14c-097f7bb6cac9.PNG" width="600" /><br />
 </p>
<h2><a class="anchor-offset" name="how-does-this-block-work"></a>How does this block work?</h2>
<p dir="auto">This block tells the distance of the current sprite from the selected object. You can click on the drop-down menu to choose the “mouse-pointer” or another “sprite” as the target object.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/67ccad19-2e44-4cc8-9acb-b6f2b4ed7bd6.PNG" width="350" /><br />
 <br />
 </p>
<h2><a class="anchor-offset" name="distance-to-mouse-pointer"></a>Distance to (mouse-pointer)</h2>
<p dir="auto">When you select “mouse-pointer” <img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7506f4db-bcd8-487d-afb3-1494e9ab5df2.png" width="70" /> as the target object, the block tells the distance from the current sprite to the mouse-pointer.</p>
<p dir="auto">As shown in the example below, whenever the "distance to (mouse-pointer) block is clicked, it tells the distance from the player (current sprite) to the mouse-pointer. This block works no matter if the mouse pointer is inside the stage window or outside of it.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/5ef7b619-8760-4677-8068-4c221f522848.gif" width="700" style="border-radius:5px;border:1px solid #29622d" /><br />
 </p>
<h3><a class="anchor-offset" name="distance-to-sprite"></a>Distance to (sprite)</h3>
<p dir="auto">When you select a “sprite” as the target object, the block tells the distance from the current sprite to the selected sprite.</p>
<p dir="auto">As shown in the example below, whenever the "distance to (Basket ball) block is clicked, it tells the distance from the player (current sprite) to the basket ball (selected sprite).</p>
<p dir="auto"><em><strong>Note: You need to have at least two sprites in the project before you can select another sprite from the drop-down list.</strong></em></p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f8d5e35a-7ef1-401f-8c81-343c4625ab7f.gif" width="700" style="border-radius:5px;border:1px solid #29622d" /><br />
 <br />
 </p>
<h2><a class="anchor-offset" name="animation"></a>Animation</h2>
<p dir="auto">Here is a basketball game animation that you can create with the “distance to (object)” block.<br />
Whenever the distance of the basketball to the basket is less than or equal to 70, the backdrop shows “GOAL”.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/94281f2f-40e7-456b-bc2e-97df96727abd.gif" width="700" style="border-radius:5px;border:1px solid #29622d" /><br />
 </p>
]]></description><link>https://forum.creaticode.com/topic/637/the-distance-to-object-block</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 00:33:22 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/637.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Sep 2022 14:41:26 GMT</pubDate><ttl>60</ttl></channel></rss>