Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I use Pathfinding?

Asked by 8 years ago

I am making a boss battle where the boss goes about his maze randomly, but I can't seem to figure out how to use PathfindingService correctly.

local pathservice = game:GetService("PathfindingService")


local path = pathservice:ComputeRawPathAsync(script.Parent.Torso.Position,  game.Workspace.Stop.Position, 100000)
script.Parent.Humanoid:MoveTo(path)

Errors: Unable to cast Instance to Vector3

1 answer

Log in to vote
1
Answered by
Hexcede 52
8 years ago

The path value I believe is an instance. Isn't there a function for the path itself to get all the points?

EDIT:

read this: http://wiki.roblox.com/index.php?title=Pathfinding#Using_a_path there is a function

-- replace your moveto(path) line with this:
points = path:GetPointCoordinates()
for _, vec3 in ipairs(points) do
    script.Parent.Humanoid:MoveTo(vec3)
end

also try setting stop's position to a random value between the edges of your map so it won't try to leave the map (not that it will as it just won't do anything)

0
Tell me if this helped you! I would be glad to hear you accept it. Hexcede 52 — 8y
Ad

Answer this question