Godot 4.5
Hello! I’m making a Smash Bros-like game, and I have this problem where one of my characters could only knockback the dummy NPC in one direction. Here’s the fighter character’s hit script:
func _on_punch_hitbox_body_entered(body: Node2D) → void:
if body.has_method(“take_hit”):
var knockback_direction = 1 if not animated_sprite.flip_h else -1
var knockback = Vector2(knockback_direction * 150, -100)
body.take_hit(knockback, 7.0)
Weirdly, it only knocks back the NPC to the RIGHT no matter which direction the character is facing. If I swap the 1 and -1 to var knockback_direction = -1 ... else 1 it only knocks back to the LEFT.
This exact script works fine on another character, but I’m not sure if this is a problem on the script or the character’s hitboxes.