ft (wip): hammerhead predator

This commit is contained in:
2026-02-02 01:41:01 +01:00
parent b21bf52938
commit 5751f25732
22 changed files with 245 additions and 45 deletions

View File

@@ -0,0 +1,22 @@
extends State
var threat: Node2D
var threshold: float = 100
func enter(previous_state_path: String, data := {}) -> void:
if data.has("threat"):
threat = data["threat"]
else:
# default behaviour; do nothing
threat = owner
func physics_update(_delta: float) -> void:
if owner.position.distance_to(threat.position) > threshold or threat == owner:
finished.emit(owner.fsm.States.IDLE, {})
return
owner.move(flee_from(threat.position))
func flee_from(pos: Vector2) -> Vector3:
var diff = threat.position - owner.position
diff = diff.normalized() * -1
return Vector3(diff.x, diff.y ,0)