This is probably about this code:
if Input.is_action_just_pressed("ui_focus_next"):
var fireball = FIREBALL.instance()
if sign($Position2D.position.x) == 1:
fireball.set_fireball_direction(1)
else:
fireball.set_fireball_direction(-1)
get_parent().add_child(fireball)
fireball.position = $Position2D.global_position
I suggest you to add some debug-prints here, just to get to see where your problem might be.
if Input.is_action_just_pressed("ui_focus_next"):
print("Creating a fireball") # for debuging, remove later
var fireball = FIREBALL.instance()
if sign($Position2D.position.x) == 1:
print("Fire in direction 1") # for debuging, remove later
fireball.set_fireball_direction(1)
else:
print("Fire in direction -1") # for debuging, remove later
fireball.set_fireball_direction(-1)
get_parent().add_child(fireball)
fireball.position = $Position2D.global_position
Now try firing in both directions and look at the console. Did your code come to the point where it should fire?
If this didn't help you find the bug, I suggest replacing the if:else: part with a single statement:
fireball.set_fireball_direction(sign($Position2D.position.x))
Perhaps that helps?