# Unwanted animation loop

Attention Topic was automatically imported from the old Question2Answer platform.

Hello, I need to know why the jump and fall animation are in a loop if I don’t indicate that.
Here is the example: loop-jump-fall.zip - Google Drive

Code:

extends KinematicBody2D

const UP = Vector2(0,-1);
const GRAVITY = 35;
const MAXFALLSPEED = 550;
const MAXSPEED = 200;
const JUMPFORCE = 1300;
const ACCEL = 30;
var motion = Vector2.ZERO;
var facing_right = true;

func _physics_process(delta):
motion.y += GRAVITY;
if motion.y > MAXFALLSPEED:
motion.y = MAXFALLSPEED;

``````if facing_right:
sprite.scale.x = 1;
else:
sprite.scale.x = -1;
motion.x = clamp(motion.x, -MAXSPEED,MAXSPEED);
``````
``````if is_on_floor():

if Input.is_action_pressed("right"):
motion.x += ACCEL;
facing_right = true;

elif Input.is_action_pressed("left"):
facing_right = false;
motion.x -= ACCEL;

else:
motion.x = lerp(motion.x,0,0.2);
animation.play("Idle");

if Input.is_action_just_pressed("jump"):
motion.y = -JUMPFORCE;

if !is_on_floor():

if motion.y < 0:
animation.play("Jump");

if motion.y > 0:
animation.play("Fall");

motion = move_and_slide(motion,UP);
``````

Because you don’t reset the `motion.y`

So lets walk through your code in reverse

``````if motion.y < 0:
animation.play("Jump");

if motion.y > 0:
animation.play("Fall");
``````

The only way those animations won’t play is if `motion.y` is absolute `0`

However in this line

``````motion.y += GRAVITY
``````

you constantly increase `motion.y` and in this next line

``````motion.y = -JUMPFORCE
``````

you rapidly decrease it ensuring `motion.y` is always above or below 0 hence your loop