Description
Tested versions
- v4.3.stable.official [77dcf97]
System information
Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 4070 SUPER (NVIDIA; 32.0.15.6603) - AMD Ryzen 7 3800X 8-Core Processor (16 Threads)
Issue description
I have attached a demo project.
If you have NavigationAgent2D with avoidance enabled and have either:
- any navigation layer selected apart from layer 1
- multiple navigation layers selected
they are by default "navigating" when first created even though no target has been set.
In other words, navigation_agent_2d.is_navigation_finished() == false
If layer 1 is selected, navigation_agent_2d.is_navigation_finished() == true
, which is correct as no target has been set yet.
Steps to reproduce
The setup:
- created a main test scene
- added a NavigationRegion2D with a NavigationPolygon, set to Navigation Layers 1
- made a new Node2D scene, added a Sprite2D and a NavigationAgent2D, enables Avoidance and connected the
velocity_computed
signal
- add this to the scene:
extends Node2D
@onready var navigation_agent_2d: NavigationAgent2D = $NavigationAgent2D
func _ready() -> void:
print("_ready:", navigation_agent_2d.is_navigation_finished())
set_physics_process(false)
print("_ready2:", navigation_agent_2d.is_navigation_finished())
call_deferred("late_init")
print("_ready3:", navigation_agent_2d.is_navigation_finished())
func late_init() -> void:
print("late_init:", navigation_agent_2d.is_navigation_finished())
set_physics_process(true)
func _physics_process (delta: float) -> void:
pass
func _on_navigation_agent_2d_velocity_computed(safe_velocity: Vector2) -> void:
pass
Added the ship to the main:
And running gives this:
This is expected.
But, if I then set the ship navigation layers to 2 as well
The output running the game is
So it has a state of not yet finished navigating, which is odd as I only changed the layer.
Then the output is also false:
Is this expected?
I know we can set a target instantly, but I was sent down a bit of a rabbit hole today wondering why my sgents wouldn't move when more than one layer was set :)
If I am being an idiot here, I am really sorry.
Minimal reproduction project (MRP)
Here is the project, I hope it's enough for you to go one.