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

@@ -34,7 +34,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
# smoothly rotate
if self.rotation != self.desired_rotation: # FIXME: causes the mirror sprites to flip out
if self.rotation != self.desired_rotation:
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
# Boundary mirroring
@@ -43,8 +43,8 @@ func _process(delta: float) -> void:
func _physics_process(delta: float) -> void:
pass
func move(motion: Vector3) -> void:
move_and_collide(Vector2(motion.x, motion.y).normalized() * self.speed) # Moves along the given vector
func move(motion: Vector3, mod: float = 1.0) -> void:
move_and_collide(Vector2(motion.x, motion.y).normalized() * self.speed * mod) # Moves along the given vector
self.desired_rotation = atan2(motion.y, motion.x)
# Apply boundary to new position
@@ -72,7 +72,7 @@ func become_injured() -> void:
mirrorSprite3.play("Injured")
func _on_sight_body_entered(body: Node2D) -> void:
if body.is_in_group("predators") or body.is_in_group("player"):
if body.is_in_group("predator") or (health < maxHealth and body.is_in_group("player")):
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": body})