delurbelako/scripts/structures/directional_sprite.gd

12 lines
329 B
GDScript

extends Sprite2D
@export var textures : Array[Texture]
@export var structure : Structure
func _ready() -> void:
structure.changed_direction.connect(on_direction_changed)
func on_direction_changed(to: float, max_directions: int) -> void:
var indexed_direction = to*max_directions/TAU
texture = textures[indexed_direction]