I can’t really write much here, because the title says it all. Thanks for any feedback though.
What do you mean by “yet keeping it smart” also you can check when the moving targets position changes and then set the NPC.Humanoid:MoveTo(target.Position)
Hi!
The pathfinding service is what you’re looking for I assume.
That way the AI will find it’s own route to the specified target.
well if I can easily just do humanoid:MoveTo() but what about the for loop with the waypoints? A player is usually moving, and if I use the same path, it’ll go to their old position, then go to their new position. I want it to continuously follow the player in a smart way. Also, I just found this out, but humanoid.MoveToFinished:Wait() makes them move extremely slow (you can see it walk then stop) , yet it gives the benefit of it being smart and go to each waypoint.
this tutorial is good, but it only goes to still targets.
Hi!
Well, you gotta have a loop, that changes the location it should go to every now and then, so it updates the location all the time, with a set interval.
I have similar NPC in my game… I dont use pathfinding because I have no obstacles for NPC, but it patrols Waypoints, and if a character gets within a certain distance, it follows and attacks them… then returns to its patrol of the waypoints.
I have it patrol waypoints using task.spawn.
well, if I make the loop a spawn function, the while loop above it will be running more paths and will make not do the right things
When you use spawn function, encase the while loop inside of it… when it is not doing the while loop, it will continue to do that spawn function.
yeah so far I tried to encase it in a spawn function and a while wait() loop, but if only MoveTo.Finished:Wait() actually worked correctly, I would have nothing to worry about
MoveTo.Finished:Wait() Works correctly, what issue are you facing with it?
it walks really choppy. In studio, if you have a good connection, it works smooth. But when it’s in a real server, they walk, then stop, walk, then stop.
Have you set the network ownership to nil on every part in the NPC?
This solved all my glitching problems.
for i,v in pairs(NPC:GetChildren()) do
if v:IsA("BasePart") then
v:SetNetworkOwner(nil)
end
end
No, I haven’t. Interesting solution, I’ll try it right now!
Here’s something I found that helped me when I was working on a wolf NPC for my game. I hope this helps.
Constantly Updating Pathfinding Path - Help and Feedback / Scripting Support - DevForum | Roblox
SilvRHat’s last post helped me the most.
I also have this in my script and it helped solve most of my issues.
This is good if the waypoints constantly move, but if they are fixed, no need for updating waypoints.
@RefusalMan Keep in mind when using MoveToFinished there is an 8 second time out… so if your NPC doesnt move to the point within that 8 seconds, you will have to call another MoveTo again, to refresh the timeout.
Simple solution ofcourse is to add more waypoints you know will not be more than 8 seconds away from each other.
yeah, so I tried, this, but the MoveToFinished:Wait() makes it move really choppy
Edit: it also goes to the old position of the player, then goes to their new position. People can easily run from the npc
okay so I got a start, where it goes through every 2 waypoints then makes a new path. But the problem here is that MoveToFinished:Wait() still makes it choppy