of     1   

Wrathsong
#184062060Sunday, February 21, 2016 7:08 AM GMT

I have the following code in all the NPCs in the game. Here are the server stats for it: prntscr.com/a60mlc Script: http://pastebin.com/2FAKBnJt How can I optimize this to get it to a low activity percentage so they it doesn't take a second or two for NPCs to take a mere step in your direction?
Wrathsong
#184062720Sunday, February 21, 2016 7:26 AM GMT

bump urgenttt
Wrathsong
#184077533Sunday, February 21, 2016 4:12 PM GMT

bumpppp...
Lua_Basics
#184077674Sunday, February 21, 2016 4:15 PM GMT

What are u trying to do with the npc's? btw can u make the code into a model because i dont use pastebin.
Wrathsong
#184078393Sunday, February 21, 2016 4:25 PM GMT

make them follow any given nearby player..and okay.. http://www.roblox.com/asdf-item?id=367216938
Lua_Basics
#184078679Sunday, February 21, 2016 4:29 PM GMT

When a player gets near? Or the CLOSEST player?
Shalaen
#184078706Sunday, February 21, 2016 4:29 PM GMT

I made a zombie using the pathfinding service, it always freaks out every now and then. More often towards the last few points. It'll quickly jolt from one side to the other.
Wrathsong
#184078792Sunday, February 21, 2016 4:31 PM GMT

the first player that gets near.
Lua_Basics
#184078935Sunday, February 21, 2016 4:33 PM GMT

its like this:? >Zombie ->Script ->Humanoid (named zombie) ->The zombie (parts)
Wrathsong
#184079073Sunday, February 21, 2016 4:36 PM GMT

yeah.
Lua_Basics
#184079259Sunday, February 21, 2016 4:39 PM GMT

hmm, well trying to fire it ONLY when u need to helps but when it gets closer* to the player that becomes irrelevant. Try firing it only so often from a distance but when they get close, fire it more often.
RulerOfTheFree
#184099368Sunday, February 21, 2016 9:27 PM GMT

Try casting a ray or two beforehand, and only using path finding service if there's an obstruction. It helps to only move to every second or third point on the path, but sometimes they get hung up on corners doing that. Why are you using RawPath instead of SmoothPath?
ha_h
#184101249Sunday, February 21, 2016 9:55 PM GMT

set log to 4*x of cancel position. that should work.. yes my siggy
filiptibell
#184101972Sunday, February 21, 2016 10:06 PM GMT

Use this instead of continiously checking the distance with that while loop: http://wiki.roblox.com/index.php?title=API:Class/Humanoid/MoveToFinished ex. local reached = script.Parent.Humanoid.MoveToFinished:wait() if reached then -- continue pathfinding else -- MoveTo didn't work, abort pathfinding end And also, use something like this to check for path timeout, instead of a loop: delay(waitTime, function() -- stuff end)
Wrathsong
#184102354Sunday, February 21, 2016 10:12 PM GMT

thanks for the input, filip!
filiptibell
#184102538Sunday, February 21, 2016 10:15 PM GMT

No problem. Remember, avoid loops if you can, use events whenever possible. Doing something very processing intensive is fine though, as long as you don't do it too often :)
Daftcube
#184103986Sunday, February 21, 2016 10:36 PM GMT

For "optimal" pathfinding, you can always implement your own version of A* or F* ;)

    of     1