2023-08-19 02:19:56 -06:00
|
|
|
extends Node3D
|
|
|
|
|
|
|
|
@onready var animation_state: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
2023-08-19 21:21:54 -06:00
|
|
|
@export var colors: Array[Color]
|
2023-08-20 01:03:30 -06:00
|
|
|
@onready var color_idx: int = randi()
|
|
|
|
var mat: Material
|
2023-08-19 02:19:56 -06:00
|
|
|
|
2023-08-19 21:21:54 -06:00
|
|
|
func _ready():
|
2023-08-20 01:03:30 -06:00
|
|
|
mat = $Armature/Skeleton3D/Slime.get_active_material(3).duplicate()
|
2023-08-19 21:58:05 -06:00
|
|
|
$Armature/Skeleton3D/Slime.set_surface_override_material(3, mat)
|
2023-08-20 01:03:30 -06:00
|
|
|
var color = colors[randi() % colors.size()]
|
|
|
|
mat.albedo_color = color
|
|
|
|
|
|
|
|
func change_color(idx: int):
|
|
|
|
color_idx = idx % colors.size()
|
|
|
|
var color = colors[color_idx]
|
|
|
|
get_tree().create_tween().tween_property(mat, "albedo_color", color, .3)
|
2023-08-19 21:21:54 -06:00
|
|
|
|
2023-08-20 01:03:30 -06:00
|
|
|
|
2023-08-19 02:19:56 -06:00
|
|
|
func walk():
|
|
|
|
animation_state.travel("Walk")
|
|
|
|
|
|
|
|
func idle():
|
|
|
|
animation_state.travel("Idle")
|