platformerNavigation/Characters/Animator.gd

21 lines
450 B
GDScript3
Raw Permalink Normal View History

2024-03-11 12:41:54 +00:00
extends Node
@onready var walk: SpriteFrames
@onready var idle: SpriteFrames
@onready var parent = get_parent()
@onready var sprite = $"../Sprite"
var facing = 1
func _process(delta):
if ! is_zero_approx(parent.velocity.x):
sprite.scale.x = 1 if parent.velocity.x > 0 else -1
if ! parent.is_on_floor():
sprite.play("Jump")
elif is_zero_approx(parent.velocity.x):
sprite.play("Idle")
else:
sprite.play("WalkRight", 2.0)