Continuation of pathfinding on isometric tilemaps

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

I managed to solve my previous issue, but a new issue popped up.
I can’t change the blue entity’s animation whenever it is pathfinding. It is stuck facing the same direction. I tried getting its velocity variable, but it does nothing.

extends KinematicBody2D

var speed = 150
var path = []
var Move
onready var goal = get_parent().get_node("RedGhola").get_global_position()

func _ready():
set_physics_process(true)
update_path()

func update_path():
path = get_parent().get_node("Nav").get_simple_path(get_position(),goal,false)

func _physics_process(delta):
var d = get_position().distance_to(path[0])
if path.size() > 1:
	if d > 2:
		set_global_position(get_global_position().linear_interpolate(path[0], (speed*delta)/d))
	else:
		path.remove(0)
func rerun():
goal = get_parent().get_node("RedGhola").get_global_position()
path = get_parent().get_node("Nav").get_simple_path(get_position(),goal,false)

Any help on this? I need to access its velocity so that it will change animations depending where its going. The rerun function allows the blue entity to keep on targetting new instances of its food.

I don’t see any code for animation here. Do you actually mean you want the blue entity to face the direction it’s going? In that case, try

look_at(goal)

Node2D — Godot Engine (3.0) documentation in English

NaughtyGnosiophile | 2018-07-31 09:11

I was trying to implement some code, and I’ve managed to have it face in the direction of its food source. It has separate animations for forward and backward. The game itself happens to be isometric, so it can’t rotate while pathfinding. It either has to switch animations, flip itself horizontally or both. What I want to do is that the blue entity faces each point on its pathfinding algorithm as it moves.

rabbitslime | 2018-07-31 10:36