I'm trying to get a kinematic body to change its animation to the appropriate isometric one as it follows a path. The code I'm using is below and it is attached to A KinematicBody2D. Any idea would be helpful even changes to structure etc.
Game
--TileMap
----Pathe2D
------PatheFollow2D
--------KinematicBody2D
--------CollisionShape2D
--------AnimationSprite
The Code Currently
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