The AnimationPlayer is playing only the 1 frame

Godot Version



extends KinematicBody2D

const UP = Vector2(0,-0.5)
const gravity = 5
const maxspeed = 100
const maxrunspeed = 200
const maxfallspeed = 300
const jumpforce = 190
const accel = 5
const run_accel = 10

var vilocity = Vector2()
var facing_right = true
var is_attackin = false

func _ready():
func _physics_process(delta):
vilocity.y += gravity
if vilocity.y > maxfallspeed:
vilocity.y = maxfallspeed

if facing_right == true:
	$Sprite.scale.x = 1
	$Sprite.scale.x = -1

vilocity.x = clamp(vilocity.x,-maxspeed,maxspeed)

if Input.is_action_pressed("right"):
	facing_right = true
	vilocity.x += accel
elif Input.is_action_pressed("left"):
	facing_right = false
	vilocity.x -= accel
	if is_on_floor():
		vilocity.x = lerp(vilocity.x,0,0.25)

vilocity = move_and_slide(vilocity,UP)


if is_on_floor():
	if Input.is_action_just_pressed("Jump"):
		vilocity.y = -jumpforce

if !is_on_floor():
	if vilocity.y < 0:
	if vilocity.y > 0:

func attack():
if Input.is_action_pressed(“attack”):
is_attackin = true
is_attackin = false
func animation():
if is_attackin == true :

Better information is needed for this question. Maybe cropping the code snippet to only the necessary lines and describing what is happening and what you’re trying to achieve. But from what I can piece together from the title and the script is, there might be an issue with how animation logic is handled

I’m not a fan of how animation are handled here. I find it’s more convenient to update animation based on physics events, not input. Here’s a tip, you can place animation logic in a function, and call in a _process.

func _process(_delta):

func update_animation():
	if is_on_floor():
		if velocity == Vector2.ZERO:
		if velocity.y < 0:
		if velocity.y > 0  && !is_on_floor():

I basically reworked the animation logic as I’m still not sure what you’re asking for specifically. Make sure to define vilocity as velocity as it seem spelt wrong. I hope this helps