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.
1 | local pathservice = game:GetService( "PathfindingService" ) |
2 |
3 |
4 | local path = pathservice:ComputeRawPathAsync(script.Parent.Torso.Position, game.Workspace.Stop.Position, 100000 ) |
5 | script.Parent.Humanoid:MoveTo(path) |
Errors:
Unable to cast Instance to Vector3
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
1 | -- replace your moveto(path) line with this: |
2 | points = path:GetPointCoordinates() |
3 | for _, vec 3 in ipairs (points) do |
4 | script.Parent.Humanoid:MoveTo(vec 3 ) |
5 | 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)