# Detect when sprites are next to each other, but not overlapping

**URL:** https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701
**Category:** Help
**Created:** [July 15, 2024, 4:43pm UTC](https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701 "2024-07-15T16:43:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gemakk](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@gemakk](https://forum.makecode.com/u/gemakk)
#### Post date: [July 15, 2024, 4:43pm UTC](https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701/1 "2024-07-15T16:43:03Z")

</div>

Hi. There’s ways to detect if a sprite is next to a wall or a particular tile, but what about another sprite?

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

I tried:

- Detecting if the image of the sprite is next to me
- Detecting if the location next to me is the same location as the sprite’s current location

Ideally, I would like to detect if a sprite of a particular _kind_ is next to me, but not overlapping.

---

<div class="post-metadata">

### Author: ![NeoStreak](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/neostreak/32/27498_2.png) [@NeoStreak](https://forum.makecode.com/u/NeoStreak)
#### Post date: [July 15, 2024, 5:05pm UTC](https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701/2 "2024-07-15T17:05:13Z")

</div>

Maybe create a hitbox, if that is possible. (I have no idea how)

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [July 15, 2024, 9:03pm UTC](https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701/3 "2024-07-15T21:03:41Z")

</div>

so if it’s a specific number of pixels away from a sprite?  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/2/d2946d48e8488048db44696f585676b4bf8656ed.png)  
sprite utils has blocks that might be helpful for that

---

<div class="post-metadata">

### Author: ![Table](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/table/32/16503_2.png) [@Table](https://forum.makecode.com/u/Table)
#### Post date: [July 16, 2024, 2:39am UTC](https://forum.makecode.com/t/detect-when-sprites-are-next-to-each-other-but-not-overlapping/29701/4 "2024-07-16T02:39:12Z")

</div>

You can put a sprite around the sprite

(using this method would require you to camouflage the box with the pixels behind it, I’d much recommend using sprite until instead)
