SlimeoosOdyssey/godot/Villager.gd

56 lines
969 B
GDScript3
Raw Normal View History

2023-08-19 11:04:45 -06:00
extends Node3D
2023-08-19 11:17:09 -06:00
var rng = RandomNumberGenerator.new()
var spin_amount = 0
var spinning = false
var wait_time = 0
2023-08-19 11:04:45 -06:00
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
2023-08-19 11:17:09 -06:00
var task = "idle"
match task:
"idle":
task = rng.randi_range(0, 100)
if task <= 33:
task = "walk"
elif task > 33 and task <= 50:
task = "spin"
elif task > 50:
task = "wait"
"walk":
pass
"spin":
if !spinning:
var spin_amount = rng.randi_range(-360, 360)
spinning = true
if spin_amount > 0:
rotate_y(5)
spin_amount -= 5
elif spin_amount < 0:
rotate_y(-5)
spin_amount += 5
else:
task = "idle"
spinning = false
"wait":
# Idle Animation goes here!
wait_time += 1
if wait_time == 100:
task = "idle"
wait_time = 0