Godot Version
4.6.2
Question
I am working on making a melee attack for my game, but the hitboxes are oriented wrong. here is my code, let me know if there is other code needed. Sorry if this is an obvious fix, I am new to godot
extends Area2D
class_name Melee
@onready var collision := $CollisionShape2D
@onready var animation_player = $"melee animations/AnimationPlayer"
@onready var sprite = $"melee animations/Sprite2D"
var facing
var direction: Vector2
func _ready():
match facing:
0: # UP
rotation = deg_to_rad(0)
animation_player.play("up_slash")
print(animation_player.current_animation)
1: # DOWN
rotation = deg_to_rad(180)
animation_player.play("up_slash")
print(animation_player.current_animation)
2: # LEFT
rotation = deg_to_rad(180)
animation_player.play("right_slash")
print(animation_player.current_animation)
3: # RIGHT
rotation = 0
animation_player.play("right_slash")
print(animation_player.current_animation)
$melee_timer.start(0.75)
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
pass # Replace with function body.
func _on_body_entered(body):
if body.is_in_group("enemy"):
body.disable_target()
#queue_free()
func _on_melee_timer_timeout() -> void:
queue_free()