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
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.
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.