# Help with raycasting collision

**URL:** <https://forum.makecode.com/t/help-with-raycasting-collision/44638>\
**Category:** Help\
**Created:** [June 21, 2026, 5:53pm UTC](https://forum.makecode.com/t/help-with-raycasting-collision/44638 "2026-06-21T17:53:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [June 22, 2026, 5:32pm UTC](https://forum.makecode.com/t/help-with-raycasting-collision/44638/3 "2026-06-22T17:32:03Z")

</div>

Turns out you can accidentally destroy the player sprite and the only thing that happens is you lose collision!  
So basically, using this code I can see that the “myself sprite” in the raycasting extension is just using the default “player” sprite type:

 ![Screenshot 2026-06-21 at 2.26.37 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/2/32830a85d10d14da18ed2840582ecc591e1d1bc5.png)  
So when you destroy all sprites of kind player later…  
 ![Screenshot 2026-06-21 at 2.26.52 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/a/3ace3f0bd812778e29109f1365c9d9dd9260a709.png)  
It deletes the player sprite too! I suspect the only thing the sprite is used for is collision handling, which is why it doesn’t break the rest of the code when you do this.  
The fix here is pretty simple, just change the sprite’s type to be it’s own type that you won’t accidentally delete:  
 ![Screenshot 2026-06-21 at 2.36.45 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/b/1bc5a2717672938ad09d61807868609c6f9895b0.png)

---

_[View the full topic](https://forum.makecode.com/t/help-with-raycasting-collision/44638)._
