0 votes

Hi Guys!

I need a help with the new pathfinding system implemented in godot 3.5.1 , it seems not creating a path who avoid static bodies, look the video above:
Path Problem error video

When the enemy needs to return the initial position, the path is not drawed and the enemy stucks in the wall.
It seems are drawing a direct line path and not one who avoid the wall.

Here is the code:

func return_Initial_pos(delta):
    if navigation_agent.is_navigation_finished():
        return_finished = true

    destination = global_translation.direction_to(navigation_agent.get_final_location())
    destination.y = 0
    var desired_velocity = destination * 20
    var steering = (desired_velocity - velocity) * delta * 4.0
    velocity += steering
    velocity = move_and_slide(velocity)
    var target_position = navigation_agent.get_target_location()
    target_position.y = self.transform.origin.y
    look_at(target_position, Vector3.UP)

Here the main scene tree:

Here the enemy tree:

Godot version 3.5.1 stable
in Engine by (21 points)
edited by

1 Answer

–1 vote

Try connecting the signal:

func _on_agent_velocity_computed(safe_velocity): velocity = move_and_slide_with_snap(safe_velocity, Vector3.DOWN, Vector3.UP, true)

by (156 points)
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 Frequently asked questions and 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 [email protected] with your username.