ft (wip): hammerhead predator
This commit is contained in:
26
evolve-die-repeat/molecular/prey/state_idle.gd
Normal file
26
evolve-die-repeat/molecular/prey/state_idle.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends State
|
||||
|
||||
@onready var timer = $Timer
|
||||
var dir = Vector3(1, 1, 0)
|
||||
var threshold = 1
|
||||
var max = 30
|
||||
|
||||
func enter(previous_state_path: String, data := {}) -> void:
|
||||
timer.start((float)(randi() % 5)/5)
|
||||
|
||||
func physics_update(_delta: float) -> void:
|
||||
if threshold == max:
|
||||
owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0), 4)
|
||||
threshold = 1
|
||||
else:
|
||||
threshold += 1
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if (randi() % 4 != 0):
|
||||
finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
|
||||
else:
|
||||
finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
|
||||
# finished.emit(owner.fsm.States.IDLE, {})
|
||||
|
||||
func exit() -> void:
|
||||
timer.stop()
|
||||
Reference in New Issue
Block a user