My navigation agent script doesn't really work, and I don't know what the reason is. Everything I've written so far is right, at least based from the codebases that I've studied. It works by manipulating the transform directly, but I want to do it with the velocity from the kinematic body through moveandslide().
It's even more harder to debug since there's no other resources I can rely to regarding this problem. Note that I've already enabled Avoidance, and this kind of algorithm words in 2D, but somehow not in 3D.
onready var navigationAgent = get_node("NavigationAgent")
onready var navigationServer = get_parent() # Parent must be a navigation node
onready var animationPlayer = get_node("AnimationPlayer")
onready var camera = navigationServer.get_node("Camera")
navigationAgent.set_target_location(camera.get_mouse_world_point()) # This bit of code just gets the mouse click position.
var nextLocation = navigationAgent.get_next_location()
var direction = global_transform.origin.direction_to(nextLocation)
var velocity = direction * navigationAgent.max_speed