Godot Version v4.3
Hi all, I’m trying to code a function that calls the “Hurt” state on my State Machine but I’m stuck on how to do it. Here’s what I tried to do:
On the Player node:
- This function receives value from Signal. It comes negative (-Value) to remove health and positive (+Value) to heal.
func _On_Player_Damaged(Value) -> void:
is_hurt(Value)
player_attributes.Current_Health += Value
print(player_attributes.Current_Health)
- Then this function determines if the player is taking damage (-Value).
func is_hurt(Value) -> bool:
if Value < 0:
return true
else:
return false
On the States of the State Machine:
3. This function calls for the “Hurt” State if is_hurt() is true.
func _on_next_transitions() -> void:
if player.is_hurt():
transition.emit("Hurt")
But I get the error “Parser Error: Too few arguments for “is_hurt()” call. Expected at least 1 but received 0.” at the States and on the is_hurt() function at the Player node I get the error that I can’t use an int with a boolean…
Is it possible to get this to work? Also, how can I implement a cooldown so the Hurt animation doesn’t get spammed if the player receives lots of damage?
Greetings and thank you for the help.