0 votes

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
in Engine by (28 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.