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.
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
Btw, I get an error: Network Ownership API cannot be called on Anchored parts or parts welded to Anchored parts.
This is why your NPC is choppy, you have anchored parts.
it’d stay in place if it did. I don’t have any anchored parts
okay so I just figured out that when it first goes in, it detects its anchored and must not be loaded all the way in. If I paste it in workspace, then put it in its npc folder (a script detects if a child is added to it) then it works. But it moves better, but it stops more clearer
Would it be possible to publish a model to Roblox with the NPC in it, so we can see the code your using?