# How do i detect the nearest sprite of a type?

**URL:** <https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556>\
**Category:** Help\
**Tags:** game, extension\
**Created:** [January 16, 2026, 7:17pm UTC](https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556 "2026-01-16T19:17:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![catto](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/catto/32/27523_2.png) [@catto](https://forum.makecode.com/u/catto)\
**Post date:** [January 16, 2026, 7:17pm UTC](https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556/1 "2026-01-16T19:17:47Z")

</div>

want to implement auto-aiming projectiles for my vampire survivors clone.  
that’s it  
yeah

> **[sogger survivors](https://arcade.makecode.com/S37008-60620-35372-69395)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Bilangus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bilangus/32/33219_2.png) [@Bilangus](https://forum.makecode.com/u/Bilangus)\
**Post date:** [January 16, 2026, 7:40pm UTC](https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556/2 "2026-01-16T19:40:50Z")

</div>

Check out this topic by Luke!

> [@\[Tutorial\] Making an Enemy Follow Multiple Sprites snake](https://forum.makecode.com/t/tutorial-making-an-enemy-follow-multiple-sprites/33914):
>
> The code gathers all the player-enemy distances, sorts them in an array to find the shortest distance, then for each player sprite, compares it’s distance to the shortest distance in the array to find the closest player. This player sprite is stored in the enemy sprite data and set as a follow target. All of this happens every game update so that the enemy can register a new closest player as fast as possible. The array before being sorted. After the sort, the 52.47… distance will be…

---

<div class="post-metadata">

**Author:** ![catto](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/catto/32/27523_2.png) [@catto](https://forum.makecode.com/u/catto)\
**Post date:** [March 2, 2026, 5:57pm UTC](https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556/3 "2026-03-02T17:57:30Z")

</div>

i wasn’t very clear before, but my intention was to have it not actively follow the enemy, but rather aim once and stay on that path.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 2, 2026, 5:58pm UTC](https://forum.makecode.com/t/how-do-i-detect-the-nearest-sprite-of-a-type/41556/4 "2026-03-02T17:58:46Z")

</div>

@catto check out the jwunderl/arcade-sprite-utils extension! there are a few blocks in there for finding the closest enemy of a type and getting the angle from one sprite to another
