Godot Version
4.2.1 stable
Question
Please save me
The character does not move in the desired direction, he just stands, although the velocity comes with a value different from 0. I created a Navigation Region3d for the map. I tried this option according to the documentation, the object just stands still.
extends CharacterBody3D
@export var movement_speed = 10
var navigation_agent: NavigationAgent3D
func _ready():
navigation_agent = $NavigationAgent3D
func set_movement_target(movement_target: Vector3):
navigation_agent.set_target_position(movement_target)
func _physics_process(delta):
await get_tree().process_frame
if navigation_agent.is_navigation_finished():
return
var next_path_position: Vector3 = navigation_agent.get_next_path_position()
var desired_velocity = (next_path_position - global_position).normalized() * movement_speed
navigation_agent.set_velocity(desired_velocity)
velocity = desired_velocity
move_and_slide()
I tried this option according to the documentation, the object just stands still.