0 votes

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.

Godot version 3.3.2
in Engine by (32 points)

1 Answer

+1 vote

i would try to add an area to the player, and one to the enemy. this can help you to understand areas better: "https://docs.godotengine.org/de/stable/classes/class_area.html"

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 :D

by (191 points)

hope this helped you ^-^

thank you very much

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.