Unit 3 lesson 20 help


I’m trying to get the dog’s score to go up only 1 if it touches the bone. What can I do to make this happen? Thank you for your help.

Here is the project link: Code.org - Game Lab

Hi @heath.kelley ,

Great question! What I see happening is the dog’s score keeps going up for as long as it’s touching the bone, and its health goes down for as long as it’s touching the bushes.

There’s a few things I can suggest asking your student to consider:

  • Is there a way to move the bone or bush as soon as the dog touches it so the variable only increments/decrements once?
  • Is there a way to use a secondary variable that changes to true when the collision is detected and doesn’t change back until the collision is no longer detected? Then the score change could be tied to this variable.

I’d recommend reviewing the lessons on collision detection toward the end of Unit 3. Your student may find something beneficial in there.

Hope that helps!

–Michael K.

1 Like