I made my own pathfinding system which uses around 0.4%-0.6%, and I am going to use 3 of these scripts. IMO they’re quite intensive. They repeat every .2 seconds checking the magnitude between maybe 50 things on top of pathfinding. I have a hard time believing this isn’t slowing down the server somehow despite it not seeming so. Is using around 1-2% script usage going to be heavy and cause server lag?
Well the pathfinding itself is a module script, but 3 seperate scripts are calling it every .2 seconds. So in the activity meter it shows 3 seperate scripts each at 0.4-0.6%
I see, is there any problem with changing it to 0.4/0.5?
If the script activity is too high, I will go through and rewrite a bulk of the code. I was curious if I need to lower it
Whole systems would need some activity while smaller scripts should be lower.
Less than 1% seems pretty standard to me with pathfinding. I made a few of my own using RunService and CollectionService, all of them manage up to 100 AI with 3-4% script activity. So, you’re not doing terrible, but always try to improve by reducing the amount of tasks being performed.
One way I did this was making a list of AI and only performing tasks when a certain criteria was met:
- If the distance magnitude is within X amount of studs
- If the AI is already doing something / pathfinding
- If the distance magnitude between the last position and the current are more than X studs
- If the AI path is blocked or completed
- Switch to Humanoid:MoveTo() when within X studs or when the destination is visible via raycast
There’s a lot of checks you can do to reduce the activity. These are just some ideas that I used and refined over several months of creating my own pathfinding.
Depends.
If you have a single Pathfinding script that uses 1%-2%, then it’s ok. If 100, then you definitely should optimize your code.
I really do not see how that would help.