SlimeoosOdyssey/godot/Models/slime.gd

27 lines
756 B
GDScript

extends Node3D
@onready var animation_state: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
@export var colors: Array[Color]
@onready var color_idx: int = randi() % colors.size()
var mat: Material
func _ready():
mat = $Armature/Skeleton3D/Slime.get_active_material(3).duplicate()
$Armature/Skeleton3D/Slime.set_surface_override_material(3, mat)
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)
func get_color():
return colors[color_idx]
func walk():
animation_state.travel("Walk")
func idle():
animation_state.travel("Idle")