Godot Version
4.4.1
Question
Hello, I have been trying to code a very simple local multiplayer game, and I am trying to make it so when the character collides with the raycast of the other one, it takes damage. The raycast part is simple, however I am having dificulty in making it reference the other character when referring to the Health Variable of the character getting hit.
if $Player1/RayCast2D/Line2D.modulate == Color.RED and $Player1/RayCast2D.is_colliding():
$Player1/RayCast2D/Line2D.modulate = Color.WHITE #Guarantes the Character deals only 1 damage
$Player2.HEALTH -= 1
This is the code I have been using , but I would like to generalize it so that it works with any character hiting any other character. When the line is red it means the hitbox for the attack is active which is why I am verifying if it’s red. How could I solve this? `