Followpath2D and animation switching

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jason Moreland

HI
I’m trying to get the ghost animation to change when he follows a path but the position returned is always (0,0) or the rotation is always 0. Its an isometric map.

Does anyone have ideas or can tell me how they do it.

the code I’m tying to use is

extends KinematicBody2D

var direction = Vector2()
var currentdirection = Vector2(0,0)

# Called when the node enters the scene tree for the first time.
func _ready():
	set_physics_process(true)
	
func _physics_process(delta):
	var dir = position
	var direction = dir.normalized()
	print(position)
	
	ghost_anim(dir)
	# Moves Ghost
	get_parent().set_offset(get_parent().get_offset() + 250 * delta)
	

func ghost_anim(direction):
	var spritedir
	if currentdirection != direction:
		if currentdirection == Vector2(-1,-1):
			spritedir = "Back_Left"
		elif currentdirection == Vector2(1,-1):
	  		spritedir = "Back_Right"  
		elif direction == Vector2(-1,1):  
	  		spritedir = "Front_Left"
		elif direction == Vector2(1,1):  
	  		spritedir = "Front_Right"
		else:
			pass
	else:
		spritedir = "Front_Left"
		
	get_node("Ghost").set_animation(spritedir)
		
	currentdirection = direction
	return currentdirection