23 lines
602 B
GDScript
23 lines
602 B
GDScript
extends CharacterBody3D
|
|
|
|
const SPEED = 1.0
|
|
const ACCEL = 4.5
|
|
|
|
@onready var nav: NavigationAgent3D = $NavigationAgent3D
|
|
@export var target: CharacterBody3D = null
|
|
|
|
#func _ready() -> void:
|
|
#pass
|
|
|
|
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()
|
|
var new_velocity = (next_location - current_location).normalized() * SPEED
|
|
if !new_velocity.is_zero_approx():
|
|
velocity = new_velocity
|
|
print(velocity)
|
|
move_and_slide()
|