Better NPC pathfinding

My current pathfinding system has the NPC following the player, but when the player moves sharply, the NPC still moves to the previous position before continuing. Is there any way I could fix this?

if you are using a loop to move the npc, make the wait time for the loop shorter

2 Likes

You just need to increase frequency of pathfinding ie. make the npc recalculate a path to the player more often. This may be a loop or event in your code which you need to edit to pathfind with shorter intervals

1 Like

the loop is set to the shortest possible time, ie task.wait() and it is in a while true do loop

One tip I’ve learnt creating pathfinding agents. ALWAYS ignore the 1st path point / < 3 points of the path as they are most likely behind and innacurate. Your NPC most of the time will be FAR infront by the time the new Path is followed if that helps.

alright, ill try that

Summary

character limit

The problem is still happening, it just keeps lagging behind

Have you tried setnetworkowner(nil) on all UNANCHORED baseparts?
Proviidng your code could greatly help

dont expect people to be able to help without any code :skull:
you posted a 3 line text, and you think we can solve the issue from that?

why do you people even get permission to speak if you ask something that cant be awnsered?

oh and the npc lagging behind is bc SERVERLAG EXISTS, YOUR CHARACTER LAGS BEHIND ON THE SERVER COMPARED TO YOUR CLIENT! GET LIGHT-SPEED WIFI OR THIS WILL ALWAYS HAPPEN

sorry, for that, but your advice fixed the issue! to be clear, the position is handled on the server, and the appearance is on the client. I had to leave, and I couldn’t solution it in time. Again, I’m sorry!