Godot Version
v4.4.stable.official.4c311cbee
Question
I have a map consisting of a ground which is a plane shaped StaticBody3D
set as child of a NavigationRegion3D
. The characters ar simple 3D nodes, not NavigationAgent
, thus to get the paths to move them around i use this function
func set_movement_path(target_position: Vector3) -> PackedVector3Array:
var start_position: Vector3 = global_position
print("TARGET POSITION: ", target_position)
current_path = NavigationServer3D.map_get_path(
GameManager.nav_mesh_rid,
start_position,
target_position,
true
)
print("PATH: ", current_path)
if not current_path.is_empty():
# Index used to go through the path points
current_path_index = 0
current_path_point = current_path[0]
return current_path
The problem is that the destination of the path has an offset from the target_position
passed to the function.
I have tried to move around an object representing an house where the characters can get inside because I have removed its CollisionShape3D
, so the problem is not that the given point is not reachable and by the way, I’ve also tried to set points manually with the same result.
These are the data I’ve got about some tests
target_position Last path point returned
-5, 0, 10 -2.50, 0, 12.25
-25, 0, 25 -27.25, 0, 27.25
-50, 0, 50 -52.25, 0, 52.25
5, 0, 10 5, 0, 12.25
25, 0, 25 25, 0, 27.25
50, 0, 50 50, 0, 52.25
5, 0, -10 3.25, 0, -12.25
25, 0, -25 23.25, 0, -27.00
50, 0, -50 48.25, 0, -52.00
-5, 0, -10 -6.75, 0, -12.00
-25, 0, -25 -26.75, 0, -27.00
-50, 0, -50 -51.75, 0, -52.00
Where could that offset come from?
The ground is positioned at (0, 0, 0), same the NavigationRegion3D
.
What should I try to check?
EDIT:
I thought to have removed the CollisionShape3D
from all the buildings, but I forgot a couple and the character was trying to get inside one with the collider still on.
The situation when the path isn’t right is this: the building’s scene has a NavigationLink3D
with the start outside and the end inside the building linking the 2 regions generated. In any case, the character doesn’t even go to the outside extremity of the link as you can see
That’s where the character stops while the target_position is inside the building.
If the buiding has no collider and does not effect the map when baked, the character gets inside.