My student is having trouble with ray casting. He made some changes and his code started glitching and giving him the error message: Program Error: sim error: failed cast on null. We can’t figure out what happened. Any help would be much appreciated.
Thanks,
Ms. G.
1 Like
Hi!
I’m not sure if there is anything else your student is looking for help with, but they are getting the “Failed cast on null error” because, in the forever loop, they are accessing the variable Clyde
when Clyde
does not get initialized until the user presses “B”. To avoid getting this error, your student can either initialize Clyde
in the on start or can add another condition in their forever condition like so:
Here is a copy of the code working (with the suggested change above implemented) if you would like to check it out: https://makecode.com/_fP7TxL6qxLz3
Thank you so much! We will definitely try that and I will let you know.
1 Like