Sim error: failed cast on 0

Hello everyone, I have a problem with my “big” project at the moment.

see screenshot
as soon as the opponent fires the projectile the error message appears

Could you share your project? If you haven’t done it before, here’s a GIF that shows how to do it:

Usually that error means that you are calling a function on a sprite before it’s been created. You might want to check your variable dropdowns to make sure you have the right sprite selected and also make sure the sprites has been created.

The bug is in this overlap event:

The variable “projectile” was never assigned to, so it’s causing the error at runtime. I think you want to use the “sprite” local variable just like you are with “otherSprite”

The way I figured this out, was by using the debugger! If you go to arcade.makecode.com/beta we’ve added exceptions to the debugger.

In other words, if you hit a simulator error while your program is running, it will pause the program and highlight the block that is causing the issue like this:

To activate the debugger, hit the bug button underneath the simulator

1 Like

THX this is a great feature :smiley: