fix enemy aligning, add sticks respawn
This commit is contained in:
+19
-3
@@ -116,11 +116,24 @@ func _chase(delta: float) -> void:
|
||||
target.take_damage(damage_to_player)
|
||||
if enemy_kick_timer <= 0.0:
|
||||
_try_enemy_kick()
|
||||
var sep := Vector3.ZERO
|
||||
for e in get_tree().get_nodes_in_group("enemies"):
|
||||
if e == self:
|
||||
continue
|
||||
var en := e as Node3D
|
||||
if en == null:
|
||||
continue
|
||||
var away := global_position - en.global_position
|
||||
away.y = 0.0
|
||||
var away_dist := away.length()
|
||||
if away_dist < 2.2 and away_dist > 0.01:
|
||||
sep += away.normalized() * (2.2 - away_dist)
|
||||
if dist > 0.05:
|
||||
var dir := diff.normalized()
|
||||
velocity.x = dir.x * move_speed
|
||||
velocity.z = dir.z * move_speed
|
||||
rotation.y = lerp_angle(rotation.y, atan2(dir.x, dir.z), 8.0 * delta)
|
||||
var move_dir := (dir + sep * 0.6).normalized()
|
||||
velocity.x = move_dir.x * move_speed
|
||||
velocity.z = move_dir.z * move_speed
|
||||
rotation.y = lerp_angle(rotation.y, atan2(move_dir.x, move_dir.z), 8.0 * delta)
|
||||
velocity.y = 0.0
|
||||
move_and_slide()
|
||||
|
||||
@@ -140,6 +153,9 @@ func _try_enemy_kick() -> void:
|
||||
var k := node as Node3D
|
||||
if k == null or not is_instance_valid(k):
|
||||
continue
|
||||
var kfv = k.get("fly_vel")
|
||||
if kfv != null and Vector2((kfv as Vector3).x, (kfv as Vector3).z).length() > 15.0:
|
||||
continue
|
||||
var d := (k.global_position - global_position)
|
||||
d.y = 0.0
|
||||
if d.length() < nearest_dist:
|
||||
|
||||
Reference in New Issue
Block a user