|
| 21 Feb 2016 01:08 AM |
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? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 21 Feb 2016 10:15 AM |
| What are u trying to do with the npc's? btw can u make the code into a model because i dont use pastebin. |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 10:25 AM |
make them follow any given nearby player..and okay..
http://www.roblox.com/asdf-item?id=367216938 |
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 21 Feb 2016 10:29 AM |
| When a player gets near? Or the CLOSEST player? |
|
|
| Report Abuse |
|
|
Itius
|
  |
| Joined: 19 Nov 2015 |
| Total Posts: 244 |
|
|
| 21 Feb 2016 10:29 AM |
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.
|
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 10:31 AM |
| the first player that gets near. |
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 21 Feb 2016 10:33 AM |
its like this:?
>Zombie ->Script ->Humanoid (named zombie) ->The zombie (parts) |
|
|
| Report Abuse |
|
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 21 Feb 2016 10:39 AM |
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. |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 03:27 PM |
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? |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 03:55 PM |
set log to 4*x of cancel position. that should work..
yes my siggy |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 04:06 PM |
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)
|
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 04:12 PM |
| thanks for the input, filip! |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2016 04:15 PM |
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 :)
|
|
|
| Report Abuse |
|
|
Daftcube
|
  |
| Joined: 10 Jan 2010 |
| Total Posts: 275 |
|
|
| 21 Feb 2016 04:36 PM |
| For "optimal" pathfinding, you can always implement your own version of A* or F* ;) |
|
|
| Report Abuse |
|
|