Godot Version
Godot 4.2.1
Question
Basically what happens is that I need to mirror a sprite horizontally, Godot didn’t highlight any errors in the script, but there must be something wrong, when I run the game and press the buttons to move the character left or right, it closes and stops responding, That’s only if I move the character, i.e. the error is in the lines where I try to mirror the sprite (25 e 27).
Script (please, ignore loopAnim function):
extends AnimatedSprite2D
@onready var PersAnim = $“.”
var SpriteToFlip = AnimatedSprite2D
func _ready():
pass
func _process(_Delta):
loopespelho()
loopAnim()
func loopAnim():
if Input.is_action_pressed("leste") or Input.is_action_pressed("oeste"):
PersAnim.play("corrida")
else:
PersAnim.play("padrao")
func loopespelho():
if Input.is_action_just_pressed("oeste"):
$AnimatedSprite2D.flip_h = 1
elif Input.is_action_just_pressed("leste"):
$AnimatedSprite2D.flip_h = 0
____________________________________________________________________________________________________.
Here’s a screenshot of Scrip (ignore loopAnim function):
Here’s a screenshot of the error message:
Here’s a screenshot of the online documentation about flip_h: