inching towards better class inheritence and multiplayer compatibility
This commit is contained in:
16
Scripts/EnemyAI/beelining_controller.gd
Normal file
16
Scripts/EnemyAI/beelining_controller.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends EnemyMovement
|
||||
class_name BeeliningController
|
||||
|
||||
var goal : Node3D
|
||||
var direction : Vector3
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
distance_remaining = character.global_position.distance_squared_to(goal.global_position)
|
||||
direction = character.global_position.direction_to(goal.global_position)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var distance_travelled = (character.stats.movement_speed * clampf(character.movement_speed_penalty, 0.0, 1.0)) * delta
|
||||
distance_remaining -= distance_travelled
|
||||
character.global_position = character.global_position + (direction * distance_travelled)
|
6
Scripts/EnemyAI/enemy_movement.gd
Normal file
6
Scripts/EnemyAI/enemy_movement.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends Node
|
||||
class_name EnemyMovement
|
||||
|
||||
@export var character : CharacterBody3D
|
||||
|
||||
var distance_remaining := 0.0
|
18
Scripts/EnemyAI/pathing_controller.gd
Normal file
18
Scripts/EnemyAI/pathing_controller.gd
Normal file
@ -0,0 +1,18 @@
|
||||
extends EnemyMovement
|
||||
class_name PathingController
|
||||
|
||||
var path : Curve3D
|
||||
var path_progress = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
distance_remaining = path.get_baked_length()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var distance_travelled = (character.stats.movement_speed * clampf(character.movement_speed_penalty, 0.0, 1.0)) * delta
|
||||
distance_remaining -= distance_travelled
|
||||
path_progress += distance_travelled
|
||||
var sample = path.sample_baked_with_rotation(path_progress, true)
|
||||
character.global_position = sample.origin
|
||||
character.look_at(character.global_position + -sample.basis.z)
|
Reference in New Issue
Block a user