If the mushroom walks into the player from the side
If the mushroom walks into the player from the side
The player will be hurt.
The player will be hurt.
To do this add a new zone to the mushroom
To do this add a new zone to the mushroom
Use an Area2D and two CollisionShape2D
Use an Area2D and two CollisionShape2D
Use RectangleShape2D for the CollisionShapes
Use RectangleShape2D for the CollisionShapes
Place them on either side of the mushroom.
Place them on either side of the mushroom.
Now Connect the body_entered signal of the HurtPlayerZone
Now Connect the body_entered signal of the HurtPlayerZone
Write code to call the Player's Hit function
Write code to call the Player's Hit function
When the player is hit by a mushroom.
When the player is hit by a mushroom.
Return to the Player script.
Return to the Player script.
Add a variable called health and set it to 3
Add a variable called health and set it to 3
Add a function called hit
Add a function called hit
In the function reduce player health by 1
In the function reduce player health by 1
Play the Hit animation.
Play the Hit animation.