Diagonal Movement Animation Problems

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MJSisShiny
extends KinematicBody2D

var movespeed : int = 80

var interactDist : int = 70

var vel : Vector2 = Vector2()
var facingDir : Vector2 = Vector2()

onready var animationPlayer = $AnimationPlayer

onready var rayCast = get_node(‘Raycast2D’)

func _physics_process(delta):

vel = Vector2()

#inputs
if Input .is_action_pressed("KeyUp"):
	vel.y -=1
	facingDir = Vector2(0, -1)
	animationPlayer.play("RunUp")
if Input .is_action_pressed("KeyDown"):
	vel.y +=1
	facingDir = Vector2(0, 1)
	animationPlayer.play("RunDown")
if Input .is_action_pressed("KeyLeft"):
	vel.x -=1
	facingDir = Vector2(-1, 0)
	animationPlayer.play("RunLeft")
if Input .is_action_pressed("KeyRight"):
	vel.x +=1
	facingDir = Vector2(1, 0)
	animationPlayer.play("RunRight")
	
if Input .is_action_just_released("KeyRight"):
	vel.x +=1
	facingDir = Vector2(1, 0)
	animationPlayer.play("IdleRight")
	
if Input .is_action_just_released("KeyLeft"):
	vel.x -=1
	facingDir = Vector2(-1, 0)
	animationPlayer.play("IdleLeft")
	
if Input .is_action_just_released("KeyUp"):
	vel.y -=1
	facingDir = Vector2(0, -1)
	animationPlayer.play("IdleUp")
	
if Input .is_action_just_released("KeyDown"):
	vel.y +=1
	facingDir = Vector2(0, 1)
	animationPlayer.play("IdleDown")

# normalized the velocity to prevent faster diagonal movement
	
vel = vel.normalized()
	
# move the player
move_and_slide(vel * movespeed)

uh, what happens. there’s nothing on the question that tells us the problem, were you trying to post a gif? Also, if you could put four spaces in front of all your code lines, they would be put in a code box and be much more readable. :slight_smile:

Millard | 2020-09-21 15:36