Check the direction of movement for different animations

I was following DevWorm’s top down rpg tutorial on youtube and for animations i wanted to make the enemy play different animation when it moves to some certain angles like if x and y both above 10 some sort of 45 ish degree angle, it will play side walk animation but if its above some angle or x y value it will play top or down talking animation. I couldnt find a way to do it and i hope i could explain my problem

This is the code

extends CharacterBody2D

var speed = 200
var player_chase = false
var player = null

func _physics_process(delta):
if player_chase:
position += (player.position - position)/speed

	if position.y < player.position.y+5:
	elif position.y > player.position.y-5:

func _on_detection_area_body_entered(body):
player = body
player_chase = true

func _on_detection_area_body_exited(body):
player = null
player_chase = false

The direction your enemy is moving in is the result of player.position - position. If you’re interested in the angle of said direction, you can do:

var direction = player.position - position
print(direction.angle()) # angle in radians
print(rad_to_deg(direction.angle())) # angle in degrees

The result of angle() is always relative to the positive x axis, that is (1, 0). There is also angle_to(...) where you have to specify the relative axis yourself.