Stand alone expressions

Godot Version

4.3

Question

I have code to stop and start animations but is says it says the code to stop the animation is a standalone expression and may not have any effect
Here is my code if it helps:
@onready var anim_player:AnimationPlayer = $PlayerBody/PlayerModel/AnimationPlayer2

func _input(event:InputEvent) → void:
if event is InputEventKey:
if Input.is_action_just_pressed(“move_forward”):
anim_player.play(“Player_Animations/Player_Walk_Anim”)
else:
anim_player.stop
if Input.is_action_just_pressed(“Move_Backward”):
anim_player.play(“Player_Animations/Player_Walk_Anim”)
else:
anim_player.stop
if Input.is_action_just_pressed(“Move_Right”):
anim_player.play(“Player_Animations/Player_Walk_Anim”)
else:
anim_player.stop
if Input.is_action_just_pressed(“Move_Left”):
anim_player.play(“Player_Animations/Player_Walk_Anim”)
else:
anim_player.stop

use stop()

1 Like