how to make enemies with health

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cobracon

in a game I’m making, the player has a sword that points toward the mouse, and the enemies have weapons that point towards the player. But, i have no idea how to make it so that the player deals damage to the enemies and vice versa.

:bust_in_silhouette: Reply From: theMX89

i would try to add an area to the player, and one to the enemy. this can help you to understand areas better: “

now you also can add an area to the sword of the player, and to the weapon of the enemy.
you can now test if the enemy/player is getting hit by the sword of the player/enemy.
If the players swords area hits the area of the enemy itself, the enemy should get damage.
if the enemys weapons area hits the players area, the player should get damage.

the code for the stuff i say here, you will probably find pretty easily on the web.
if not, feel free to ask me :smiley:

hope this helped you ^-^

theMX89 | 2021-10-11 20:47

thank you very much

cobracon | 2021-10-11 21:42