2025-01-02 12:09:30 +01:00
|
|
|
extends CharacterBody3D
|
|
|
|
|
|
|
|
|
|
const SPEED = 1.0
|
|
|
|
|
const ACCEL = 4.5
|
|
|
|
|
|
|
|
|
|
@onready var nav: NavigationAgent3D = $NavigationAgent3D
|
|
|
|
|
@export var target: CharacterBody3D = null
|
|
|
|
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
|
|
|
if not target:
|
|
|
|
|
return
|
|
|
|
|
nav.set_target_position(target.global_position)
|
|
|
|
|
var current_location = global_transform.origin
|
|
|
|
|
var next_location = nav.get_next_path_position()
|
2025-01-02 14:05:21 +01:00
|
|
|
var dist = next_location - current_location
|
|
|
|
|
var new_velocity = dist.normalized() * SPEED
|
|
|
|
|
if dist.length() > 0.5:
|
2025-01-02 12:09:30 +01:00
|
|
|
velocity = new_velocity
|
|
|
|
|
move_and_slide()
|