# How to make enemies spawn and approach player in radius

**URL:** <https://forum.makecode.com/t/how-to-make-enemies-spawn-and-approach-player-in-radius/29387>\
**Category:** Help\
**Tags:** game\
**Created:** [June 21, 2024, 4:27pm UTC](https://forum.makecode.com/t/how-to-make-enemies-spawn-and-approach-player-in-radius/29387 "2024-06-21T16:27:37Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![anon30657772](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon30657772](https://forum.makecode.com/u/anon30657772)\
**Post date:** [June 21, 2024, 7:02pm UTC](https://forum.makecode.com/t/how-to-make-enemies-spawn-and-approach-player-in-radius/29387/4 "2024-06-21T19:02:23Z")

</div>

Someone recently asked **[a similar question](https://forum.makecode.com/t/closest-player-to-an-enemie/29343)**!

You can use **[this](https://github.com/jwunderl/arcade-sprite-util)** extension which has this built-in block to get distance between sprites (and lots of other handy stuff 🤩)

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0eb3866671fe8d8569f8340d82ac545cf1437d92.png)

As for your _own_ code, the reason it’s not working is because you called the radius check function only in the “On start” block! If you put it in a “Forever” block, it will work like **[this](https://arcade.makecode.com/S00391-43170-21553-31585)**!

---

_[View the full topic](https://forum.makecode.com/t/how-to-make-enemies-spawn-and-approach-player-in-radius/29387)._
