0 votes


Sorry if this is a stupid question.
I am running the current version of Godot and I have come across an issue with my navigation.

It's a pretty simple "follow the player scenario", everything works well unless the "AI" has to traverse a slope. On the beginning of a slope it floats over ground and then on the top of a slope it sinks underground.

I have tried changing the NavMesh properties multiple times but I have not found a solution.

I am attaching the agent code and the shape itself is a simple capsule.

Is there a way to keep the agent grounded at all times or is there any other/better way to do the 3D navigation?

extends KinematicBody

var player = null

var can_move = true

var path = []
var path_ind = 0
var move_speed = 3
onready var nav = get_parent()

func _process(delta):
    if Input.is_action_just_pressed("debug_1"):
        can_move = false
    if Input.is_action_just_pressed("debug_2"):
        can_move = true

func _physics_process(delta):
    if can_move == true:
        if path_ind < path.size():
            var move_vec = (path[path_ind] - global_transform.origin)
            if move_vec.length() < 1:
                path_ind += 1
                move_and_slide(move_vec.normalized() * move_speed, Vector3(0, 1, 0))

        transform.origin.y = $RayCast.get_collision_point().y

func move_to(target_pos):
    path = nav.get_simple_path(global_transform.origin, target_pos)
    path_ind = 0

func set_player(p):
    player = p

func _on_Timer_timeout():
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.