diff options
Diffstat (limited to 'scripts/enemy.gd')
-rw-r--r-- | scripts/enemy.gd | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/enemy.gd b/scripts/enemy.gd index 8c5652f..41f1669 100644 --- a/scripts/enemy.gd +++ b/scripts/enemy.gd @@ -21,12 +21,16 @@ var original_material: StandardMaterial3D var mesh_ready = false var found = false +var dead: bool = false + func _ready() -> void: if gravity_enabled: motion_mode = MotionMode.MOTION_MODE_GROUNDED NavigationServer3D.connect("map_changed", map_changed) - original_material = $MeshInstance3D.get_active_material(0) + $alien/AnimationPlayer.play("Idle") + $alien/AnimationPlayer.seek(randf()) + #original_material = $MeshInstance3D.get_active_material(0) func map_changed(_rid): print("Map changed") @@ -36,7 +40,7 @@ func update_target_location(target_location: Vector3): nav_agent.target_position = target_location func chase_nav_mesh(delta: float): - if not mesh_ready: + if not mesh_ready or dead: return if target != null: @@ -60,6 +64,9 @@ func chase_nav_mesh(delta: float): move_and_slide() + if velocity.length_squared() > 0.1: + look_at(current_location + velocity) + func wander() -> void: pass @@ -90,11 +97,14 @@ func check_target_visible() -> bool: func on_hit(_hit_position: Vector3) -> void: if $HitTimer.is_stopped(): - $MeshInstance3D.set_surface_override_material(0, red_material) + #$MeshInstance3D.set_surface_override_material(0, red_material) + $alien/AnimationPlayer.play("Dead") + $HitTimer.wait_time = $alien/AnimationPlayer.current_animation_length $HitTimer.start() + dead = true func _on_hit_timer_timeout() -> void: - $MeshInstance3D.set_surface_override_material(0, original_material) + #$MeshInstance3D.set_surface_override_material(0, original_material) $HitTimer.stop() get_parent().remove_child(self) |