Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Am I missing something with this pathfind?

(The code is a simple pathfind script that computes a path and makes a part trail on it)

http://i.imgur.com/Pi8Fcuy.png

^ As you can see, the path seems to not be able to exist once it goes onto the sand, and i'm not sure why. Notes:

All of the walls and the floors of the bases are unions The sand is perfectly positioned next to the baseplate

3 comments

0

For using an AI use ComputeSmoothPathAsync instead

0

There are going to be alot of NPC's, and they have very simple Ai, so raw path is better for performance purposes.

0

Okay, Hmm I'll do more research and I'll give you the answer soon.

1 answer

The problem might be how the game sees if a part of the game is empty or not. ROBLOX's Pathfinding finds a path from point a to point b without any walls/holes. So when a space is 16% filled the game decides to say "There is a hole here!". This is because of the EmptyCutoff. It is set to 0.16 which is 16%. So if 16% or less of the 4x4x4 area is not filled, it is considered empty. To resolve this problem there is 2 solutions:


#Resize the sand/base There is a chance the sand/baseplate is too short and Pathfinding doesn't do well with small, thin parts. Resize it on the y axis, that might fix it! If not... Do next solution:


#Change the EmptyCutoff Change the empty cutoff to a number 0-1. If it's 0, then it will always be full, if it is 1, it will always be empty. Change this number to a reasonable number like 8% would mean you would have to fill more than 8 studs in a 4x4x4 area to be considered filled. Make sure it won't be too low or it might end up walking somewhere it shouldn't.

local pathfind = game:GetService("PathfindingService")
pathfind.EmptyCutoff = 0.8 --8%


Hope it helps!

1 comment

0

This isn't working, even if I set EmptyCutoff to 0. The sand is 6 studs Y.

This discussion is preserved as it was. New answers, comments, and votes are closed.