Unit 3 Lesson 27 Debug Help

I have a student trying to get their character to change animation when the “g” key it hit. Everything appears to work except that part. The character doesn’t change. It will move left and right when the D and A keys are pressed. Also, his score will not increase as the game goes on as well. Any help would be much appreciated.
Here is a link to the project: Code.org


1 Like

Hi @stephanie.hodgson,

Can you click the SHARE button on his project and then share that link? When I click on the link you posted, it just takes me to my Unit 3, Lesson 27, Bubble 2 - I can’t see your student’s project. Thanks.


Sorry about that. I thought that was the link they gave me.

Here is the shared link: https://studio.code.org/projects/gamelab/U1Z19ZtG0_8Sh59uxVSGJUio3G73FckdxX4dterlOPM


It was hard to see the differences in the sprites! I had to scale it x 2. The other troubleshooting step I took was to try to switch it with a really different sprite so I knew for sure it wasn’t working and it was not. I placed a console.log in the function that is supposed to change the animation and it did run meaning the function is running but the animation isn’t changing. So, when that happens I think about what is also running that is opposing the animation change.

On line 69, I see an else and if the else is triggering, the animation for Jim is always animation_1 so he won’t change to gun. I don’t think you need the else statement on line 69 because the default animation is animation_1. In my mind, if the g key is down, then the animation is gun, else it is animation 1 (so try moving the else statement that changes the animation to gun to the conditional with the g key).

Hope that makes sense. Good luck!

Thank you. We are going to give it a try.