WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
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? |
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
bump
urgenttt |
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
bumpppp... |
|
|
What are u trying to do with the npc's? btw can u make the code into a model because i dont use pastebin. |
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
make them follow any given nearby player..and okay..
http://www.roblox.com/asdf-item?id=367216938 |
|
|
When a player gets near? Or the CLOSEST player? |
|
ShalaenJoin Date: 2015-11-19 Post Count: 357 |
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.
|
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
the first player that gets near. |
|
|
its like this:?
>Zombie
->Script
->Humanoid (named zombie)
->The zombie (parts) |
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
yeah. |
|
|
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. |
|
|
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_hJoin Date: 2013-05-18 Post Count: 1695 |
set log to 4*x of cancel position. that should work..
yes my siggy |
|
|
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)
|
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
thanks for the input, filip! |
|
|
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 :)
|
|
DaftcubeJoin Date: 2010-01-10 Post Count: 275 |
For "optimal" pathfinding, you can always implement your own version of A* or F* ;) |
|