4.3
When I bake my navigation polygon im getting all these numerous cuts rather than a solid surface, any ideas as to what might be causing this?
4.3
When I bake my navigation polygon im getting all these numerous cuts rather than a solid surface, any ideas as to what might be causing this?
What do you mean cuts? For a tilemaplayer you may see more triangles but they are one navigation mesh
i was led to believe they should look like one solid mesh. I ask because it seems to be causing pathfinding to not work (npcs jittering all over).
Can you share some of the npc code? This looks like a normal (maybe sub-optimal) navigation mesh, whereas jittery pathfinding is a very common problem.
Certainly, heres the code my npc has
extends CharacterBody2D
@export var follow_target: Node2D
@export var navigation: NavigationRegion2D
var speed := 90
var last_direction := “down”
var path :=
var path_index := 0
func _ready() → void:
add_to_group(“followers”)
func _physics_process(delta):
if not follow_target or not navigation:
return
# Recalculate path if target moved significantly or path is empty
if path.size() == 0 or follow_target.global_position.distance_to(path[-1]) > 8:
path = NavigationServer2D.map_get_path(
navigation.get_navigation_map(),
global_position,
follow_target.global_position,
false
)
path_index = 0
if path.size() > 1 and path_index < path.size():
var next_point = path[path_index]
var direction = next_point - global_position
if direction.length() < 4 and path_index < path.size() - 1:
path_index += 1
next_point = path[path_index]
direction = next_point - global_position
if direction.length() > 1:
var move_vec = direction.normalized()
velocity = move_vec * speed
# 8-directional animation logic (same as before)
if move_vec.x > 0.5 and move_vec.y < -0.5:
last_direction = "up_right"
elif move_vec.x < -0.5 and move_vec.y < -0.5:
last_direction = "up_left"
elif move_vec.x > 0.5 and move_vec.y > 0.5:
last_direction = "down_right"
elif move_vec.x < -0.5 and move_vec.y > 0.5:
last_direction = "down_left"
elif abs(move_vec.x) > abs(move_vec.y):
last_direction = "right" if move_vec.x > 0 else "left"
else:
last_direction = "down" if move_vec.y > 0 else "up"
$AnimatedSprite2D.play("walk_%s" % last_direction)
else:
velocity = Vector2.ZERO
$AnimatedSprite2D.play("idle_%s" % last_direction)
else:
velocity = Vector2.ZERO
$AnimatedSprite2D.play("idle_%s" % last_direction)
move_and_slide()