I have a problem with fail to cast on null

I am having troubles with failed to cast on null, I dont know where to begin I am kinda new and my code is kinda big.

Link to the project

1 Like

Welcome @kknuser and nice game!

Running the game in debug mode indicates that the sprite mirror_master might be referenced inside the forever loop before it is created.

2 Likes

It looms like the reason your getting the error is because your trying to reference the sprite “mirror_master” in the forever loop before it’s created:


To avoid the null error, I’d suggest either:
creating the mirror_master sprite at the start of the game,
make sure if mirror_master has been created before the if statements, which would look like this:

or preferably use the “Move (Sprite) With Buttons” to move mirror_master as it automatically checks if the sprite has been created.
Hope that helps!

2 Likes