ft: predator mostly done

This commit is contained in:
2026-02-06 12:43:37 +01:00
parent 5f9a2fffb9
commit 8ee70854ea
16 changed files with 271 additions and 30 deletions

View File

@@ -8,7 +8,7 @@ func enter(previous_state_path: String, data := {}) -> void:
threat = data["threat"]
else:
# default behaviour; do nothing
threat = owner
finished.emit(owner.fsm.States.IDLE, {})
func physics_update(_delta: float) -> void:
if owner.position.distance_to(threat.position) > threshold or threat == owner:

View File

@@ -2,25 +2,18 @@ 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
owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0), 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, {})
finished.emit(owner.fsm.States.IDLE, {})
func exit() -> void:
timer.stop()

View File

@@ -4,7 +4,7 @@ extends State
var dir: Vector3 = Vector3(0,0,0);
func enter(previous_state_path: String, data := {}) -> void:
timer.start((float)(randi() % 10)/20)
timer.start((float)(randi() % 10)/5)
dir = calc_dir(randi() % 360)
func physics_update(_delta: float) -> void:
@@ -14,7 +14,8 @@ func calc_dir(angle: float) -> Vector3:
return Vector3(cos(angle), sin(angle), 0)
func _on_timer_timeout() -> void:
finished.emit(owner.fsm.States.IDLE, {})
finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
#finished.emit(owner.fsm.States.IDLE, {})
func exit() -> void:
timer.stop()