Help with raycasting collision

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:


So when you destroy all sprites of kind player later…

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:

5 Likes