4-directional 2D character Spell projectile flying and rotation problem

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Cryothenir

Hello and thanks for trying to help!
I tried to create a spell for my 2d rpg character so that when the character faces either up,down,right or left the spell would also shoot that direction.

Direction is confirmed with button pushes with arrows and works with walking, hitting etc… but this spell is all over the place, most of the times this spell goes down but sometimes the direction it is supposed to go.
I have no idea what is off.

Also spells that are shot out also change direction when i move around with my character.

So summary:

  1. I want a spell that shoots the same direction the character is looking at.
  2. Bonus: I want the spell projectile to be facing the way it goes also (0code for that atm and I cant even begin to figure out how to do that, but I wanted the spell to fly the right way first anyways).

`

func cast():
	if Input.is_action_just_pressed("SpellCast"):
		cast = true
		var position_spawn = $SpellPosition.global_position
		create_spell(position_spawn)
		if direction == "Left":
			get_parent().get_node("Spell").motion = Vector2(-500, 0)
			$SpellPosition.position = Vector2(-360, 0)
			$AnimatedSprite.play("Left_Hit")
			cast = false
		if direction == "Right":
			get_parent().get_node("Spell").motion = Vector2(500, 0)
			$SpellPosition.position = Vector2(360, 0)
			$AnimatedSprite.play("Right_Hit")
			cast = false
		if direction == "Up":
			get_parent().get_node("Spell").motion = Vector2(0, -500)
			$SpellPosition.position = Vector2(0, -360)
			$AnimatedSprite.play("Back_Hit")
			cast = false
		if direction == "Down":
			get_parent().get_node("Spell").motion = Vector2(0, 500)
			$SpellPosition.position = Vector2(0, 360)
			$AnimatedSprite.play("Front_Hit")
			cast = false

func create_spell(pos):
	var spell = Spell.instance()
	spell.set_position(pos)
	get_parent().add_child(spell)
	return spell

`