sprite in the correct direction

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

I wanted to make the bullet go in the direction where the player is, it really happens but the sprite remains static, how do you solve this?

func fire():
	 if Input.is_action_just_pressed("shoot"):
		var direction = 1 if not $anim.flip_h else -1
		var f = bullet.instantiate()
		f.direction = direction
		f.position.y = position.y
		f.position.x = position.x

Edited to fix code formatting. To do that next time, after pasting code into your post, select the code block and press the {} button.

jgodfrey | 2023-05-07 18:51

thank you, and that i’m new around here

cabralito | 2023-05-07 18:53