#enemy Pathfinding stutering when tracking player

1 messages · Page 1 of 1 (latest)

hot stone
#

https://www.youtube.com/watch?v=NH0DmvxlvoE heres a video of the npc stuttering,
also a few things to consider when responding to this help request

  1. I am inexperienced and i dont know alot about coding, i have also taken a long break before this so i may make very silly mistakes.
  2. Please be patient, and if you dont wanna work with someone who likely wont understand explanations the first time, then ignore this post.
  3. i did get this code from a forum, i have an understanding of how it works but not enough to replicate it with no reference.

also a person who commented on the stuttering said that it had something to do with the heartbeat function being inefficient.

amber sentinel
#

can pretty much guarantee you're using movetofinished:wait()

amber sentinel
hot stone
#

alr thanks ill check the post out

oak scarab
#

shutdown!!!!

oak scarab
#

YESSIR

amber sentinel
#

i said it before 6 months ago and I say it again now:
i'm not sure where yall getting this newb trap from but whoever started it should be poked with a rusty spoon istg

oak scarab
#

Sank you for your wisdom

proud karma
amber sentinel
proud karma
amber sentinel
#

just trust me, you need to follow the character pathfinding page and how it connects to movetofinished instead of waiting for it.

#

this lets you interrupt the movement to give it a new path instead of waiting for it to finish its current path before moving along a new path. the wait just locks up the entire thing

#

you cannot interrupt it

#

e.g pathfind to player and using movetofinished:wait()? oh sorry the player just moved and now you're still waiting for the old path to finish being followed. and then people complain "why is my npc pathfinding stuttering/slow"

#

and the answer is always because you fell for the noob trap and cannot interrupt the pathfinder with a new path

#

... that's before the 8 second timeout problem on movetofinished

proud karma
amber sentinel
#

if you don't have line of sight and need to pathfind around obstacles, you need to use pathfindingservice. and again, if you just movetofinished:wait(), the npc will stutter because it waiting for movetofinished and then generates a new path after the npc stopped, which can take a second or so. during that time the npc is just standing in place not moving at all because you insisted on using the noob trap.

#

it's better to regularly pathfind, allow the npc to follow the path until the new path is available - that way the movement is never stopped entirely

#

then when there is line of sight you can moveto directly towards the target position, but not before then, and again even if you do that - if you used movetofinished:wait(), that code is still waiting and now you've got 2 blocks of pathfinding code running at the same time

amber sentinel
proud karma
#

For i = 1,10 do
Moveto
Movetowait
End

amber sentinel
proud karma
hot stone
#

im kinda having trouble with the doc

#

can anyone help me with it? or does anyone have like a video of someone using movetofinished() using connections instead of just using it outright

amber sentinel
#

the docs have a copypaste section of code for it

#

there's lots of tutorials on pathfindingservice you just need to look for it

#

if any of them use movetofinished:wait find a different tutorial

hot stone
#

https://www.youtube.com/watch?v=tjwI4b2ZRZk ok i think i finally found a tutorial using movetofinished:connect() the first 9 videos shown in the search are just using it without a connection

In this Roblox Studio tutorial, I demonstrate how to get an NPC to use Pathfinding links to allow for extra pathfinding behavior! Handled blocked paths, climb ladders and swim to the goal.

https://www.roblox.com/library/12289088524/ObbyForPathFinding
https://www.roblox.com/library/12289151435/Simple-Ladder
https://www.roblox.com/library/123015...

▶ Play video
night pagodaBOT
#

studio** You are now Level 1! **studio

hot stone
#

ok so when calling the followpath function do i use my target instead of a part

hot stone
#

so first screen shot is variables second is targeting function and third is pathfinding

#

anyone know how i would get it to loop the pathfinding without it jittering?