0 votes

THIS IS ENEMY
https://imgur.com/a/kNImvXx

I have another character and throw punch like that...

https://imgur.com/a/5iVQjR7

The problem is i already set health ready func but how can i implement hitbox
and give damage from player to enemy. For example jab give 5 damage and take from enemy's health etc.

How can i build this algorithm any instructions out there or documentation ?

func _ready():
var health = 30
# Called when the node is added to the scene for the first time.
# Initialization here
pass

Thanks for answers...

asked Jan 27, 2019 in Projects by presentxy (12 points)

2 Answers

0 votes

I don't know if it is the best way, but I would use RayCast2D and Area2D nodes. Create Area2D nodes for the players' bodies, then have RayCast2D nodes that reach as long as a player's arm when they are punching. Using a state machine, if the player is_punching and the raycast is colliding, then you know that the player has "hit" the other player. Then just minus 5 from the health.

Hope this helps :)

Finite State Machine
Raycast2D
Area2D

answered Jan 27, 2019 by i_love_godot (352 points)

I would also recommend seeing the tutorial from KidsCanCode on youtube (the tank down kne). I learned a lot about health and other stuff there

0 votes

Use another collider box names would be damagebox. And damagebox only should be colliding with a hitbox,you need to set collisionlayer,mask for this. And if colliding is happen then subtract health var.

answered Jan 27, 2019 by LordViperion (190 points)
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.