Attack distance

I am thinking about adding more levels and other feature to my earlier platform game.

The main thing I want to add is the ability for the platform character that is a dog to bark at enemies to beat them but I only want the player to be able to defeat the enemy when they only a certain distance from the enemy.

How can I achieve this

Thank you

The dog is the player character, right?
When barking, create an invisible Sprite at the dog’s mouth and check if it is colliding with an enemy. After done barking make sure to delete the sprite (much like a hitbox).

1 Like