Godot 4.3
Hello! I’m trying to make my animations switch up when certain things happen, so when you press left or right, the idle animated sprite 2d disappears and the walking animated sprite 2d. But certain animations won’t go away (The reason for the different animated sprite 2d’s is because of the different canvas sizes for all of them). For example the walking and idle animation don’t go away when the run button is pressed. Can someone help?
BTW The animated sprite 2d “Animations” is for the idle, just letting you guys know.
if Input.is_action_just_pressed("left"):
if Input.is_action_just_pressed("run") == false:
$Walk.show()
$Walk.play("walk")
$Animations.hide()
if Input.is_action_just_pressed("right"):
if Input.is_action_just_pressed("run") == false:
$Walk.show()
$Walk.play("walk")
$Animations.hide()
if Input.is_action_just_pressed("left"):
if Input.is_action_just_pressed("run") == true:
$Walk.hide()
if Input.is_action_just_pressed("right"):
if Input.is_action_just_pressed("run") == true:
$Walk.hide()
if Input.is_action_just_released("left"):
$Walk.hide()
$Animations.show()
if Input.is_action_just_released("right"):
$Walk.hide()
$Animations.show()
if Input.is_action_just_pressed("run"):
SPEED = 670
$Run.show()
$Run.play("Run")
$Animations.hide()
$Walk.hide()
if Input.is_action_just_released("run"):
SPEED = 450
$Run.stop()
$Run.hide()
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * SPEED
$Walk.play("walk")
else:
velocity.x = move_toward(velocity.x, 0, 22)