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:58:11 -06:00
|
|
|
var walking = false
|
|
|
|
var walk_dist = 0
|
2023-08-19 11:17:09 -06:00
|
|
|
|
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":
|
2023-08-19 11:58:11 -06:00
|
|
|
if !walking:
|
|
|
|
walk_dist = rng.randi_range(0, 20)
|
|
|
|
walking = true
|
|
|
|
|
|
|
|
if walk_dist > 0:
|
|
|
|
# Small change to turn a little while walking.
|
|
|
|
var spin_chance = rng.randi_range(0, 10)
|
|
|
|
if spin_chance <= 1:
|
|
|
|
rotate_y(5)
|
|
|
|
|
|
|
|
|
2023-08-19 11:17:09 -06:00
|
|
|
|
|
|
|
"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
|
|
|
|
|
|
|
|
|
|
|
|
|