#3D Navigation Agent Avoidance

10 messages · Page 1 of 1 (latest)

blissful jackal
#

To be clear, are you referring to using NavigationAgent3D with Avoidance enabled or specifically using Use 3D Navigation property within a NavigationAgent3D?
Might also help to include a small video snippet of your issue, and include your NavigationAgent3D properties, at minimum.

lucid path
# blissful jackal To be clear, are you referring to using `NavigationAgent3D` with Avoidance enab...

I am referring to NavigationAgent3D nodes with Avoidance enabled. No I do not need the Use 3D feature, though I have tested it with this enabled. I can include a video but it's really as simple as as soon as I enable Avoidance, all it does slow the enemies. The Avoidance values are the initial values. The setup is basically the same one as in the documentation where when they have Avoidance enabled, the physics_process simply updates the target destination and the movement is handled in the velocity_computed signal. But like I said, it just slows down my character as if they're not moving every physics frame anymore and they don't even avoid each other. I will include a video shortly

lucid path
#

This is the relevant movement script code that gets called every physics frame:

        var movement_delta: float = enemy.speed * delta
        if enemy.nav_agent.avoidance_enabled:
            enemy.nav_agent.set_velocity(direction * movement_delta)
        else:
            enemy.on_velocity_computed(direction * movement_delta)

Basically if avoidance_enabled is true, all I do is set the velocity for the nav agent. Otherwise, I manually call the velocity_computed callback function. Which is just a simple movement script. As far as I can tell, this is exactly how it's done in the documentation

#

And this is the on_velocity_computed function that either gets called every physics frame if avoidance is NOT enabled or gets called when the velocity_computed signal of the NavigationAgent3D gets triggered.

func on_velocity_computed(safe_velocity: Vector3) -> void:
    if not (state_manager.current_state is EnemyStateNormal):
        return 
    move_and_collide(safe_velocity)
#

This is the documentation code I followed: https://docs.godotengine.org/en/4.0/tutorials/navigation/navigation_using_navigationagents.html#doc-navigation-using-navigationagents

You can see that they only use their physic_process to set values and then all the real movement is handled in the _on_velocity_computed() function.

#

At first I thought the problem was that I was passing movement_delta into the on_velocity_computed() function, because the move_and_collide() function within that callback already handles delta, but changing my code to enemy.on_velocity_computed(direction * enemy.speed) gives the exact same results. Which is weird in itself if you ask me

#

And also avoidance is non existent as far as I can tell, so there's also that as well

blissful jackal
#

It looks like you are using a RigidBody3D as your base scene. I think you need this example, instead: https://docs.godotengine.org/en/4.0/tutorials/navigation/navigation_using_navigationagents.html#actor-as-rigidbody3d

Notably, it should be changing the linear_velocity in _on_velocity_computed

Also, worth checking that the Max Speed on the NavigationAgent3D is not causing issues.