I need help with a game

I need help I have a game so there is a bear walking in a maze I want it if the bear touches the wall of the maze it loses health with a variable but when he touches it the player can just hug the wall and not lose health so the code is only actevating 1 time.

i have the same problem in my game in cospace!

Hi Charlie and Logan,

Here is an example CoSpace I made to show one way to have constant damage occur from a collision with an object (like walls). You can Remix it to see the full code. I also added some screenshots below for reference.


The first screenshot shows the walls as children of a “Parent Wall.” I added all the children walls (the maze walls) to a list, so we can keep track of them.

The “when” CoBlock is checking to see if our player touches anything in the scene. When it does, it checks each object inside our wall list to see if that is what we collided with. If we did touch a wall, it sets the “isTouchingWall” variable to true. Our “if” statements check for that variable, and if it is true, we lose health. Once we stop colliding with the wall, it sets that variable back to false and we stop losing health.

Omg thank you so much.

1 Like