18 lines
609 B
GDScript
18 lines
609 B
GDScript
extends Node2D
|
|
|
|
|
|
@export var animation_tree: AnimationTree
|
|
@onready var player : Player = get_owner()
|
|
|
|
var last_facing_direction = Vector2(0,-1) # facing south
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
var idle = !player.velocity
|
|
if !idle:
|
|
last_facing_direction = player.velocity.normalized()
|
|
animation_tree.set("parameters/walking/blend_position", last_facing_direction)
|
|
animation_tree.set("parameters/idling/blend_position", last_facing_direction)
|
|
animation_tree.set("parameters/grabing/blend_position", last_facing_direction)
|