4.2
Hi i keep getting this error
What is wrong in my code idk how to fix this please it keeps saying the error
but the pathfinding seems fine even tho it kind of looks weird and theres no paths in the debug visible paths and kind of slow
extends CharacterBody3D
var grav:float = -9.8
var walkspd:float = 10
@onready var agent:NavigationAgent3D = $NavigationAgent3D
func _ready():
pass
func _physics_process(_delta):
# the gravity.
if not is_on_floor():
velocity.y += grav
if velocity.y < grav:
velocity.y = grav
var nextloc = agent.get_next_path_position()
var newvel = (global_position.direction_to(nextloc) * walkspd).normalized()
velocity = newvel
move_and_slide()
func updateloc(targetpos):
agent.target_position = targetpos.global_transform.origin
Can you show us the exact error message (Copy and paste it) as well as tell us where this error is occuring? During which call?
Its on the 18 line of code the get_next_path_positions()
â—Ź00.00.00.03751 mrevil.gd.18@ physics_process(): NavigationServer map query failed because it was made before first map synchronization
Does this happen all the time, or only when you start the game / load that specific scene?
I suspect this happens because physics_process gets called before the NavigationServer is properly initialized. Try to delay for the first few frames, maybe have a boolean that says “isInitialized” that is set to false by default. If it’s false, simply pass the current physics_process check, and in the _ready function, make a deferred call to a function that sets the isInitialized boolean to true.
Thanks it works now but my pathfinding line still doesnt appear (and also thr guy is a bit dumb)
Never the less thanks!!!111