Vritix
|
  |
| Joined: 01 Jan 2011 |
| Total Posts: 2790 |
|
|
| 08 Aug 2015 10:22 PM |
| Is it possible to use like a model of bricks for pathfinding, instead of a character, or a dummy? |
|
|
| Report Abuse |
|
|
| |
|
Vritix
|
  |
| Joined: 01 Jan 2011 |
| Total Posts: 2790 |
|
| |
|
|
| 08 Aug 2015 10:28 PM |
-- In Script in ServerScriptService local pathfindingService = game:GetService("PathfindingService") local pointModel = Instance.new("Model") pointModel.Name = "Points" pointModel.Parent = game.Workspace -- Setup remote function local remoteFunction = Instance.new("RemoteFunction") remoteFunction.Parent = game.ReplicatedStorage function visualizePath(path) -- clear old path visualization for _, point in pairs(pointModel:GetChildren()) do point:Destroy() end -- calculate new visualization local points = path:GetPointCoordinates() for _, point in pairs(points) do local part = Instance.new("Part") part.Parent = pointModel part.FormFactor = Enum.FormFactor.Custom part.Size = Vector3.new(1,1,1) part.Position = point part.Anchored = true part.CanCollide = false end end game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player, target) local start = player.Character.Torso.Position local path = pathfindingService:ComputeRawPathAsync(start, target, 500) visualizePath(path) -- Check to see if the path was computed correctly if path.Status == Enum.PathStatus.FailStartNotEmpty or path.Status == Enum.PathStatus.FailFinishNotEmpty then print("Compute failed") return {} end return path:GetPointCoordinates() end |
|
|
| Report Abuse |
|
|
Vritix
|
  |
| Joined: 01 Jan 2011 |
| Total Posts: 2790 |
|
|
| 08 Aug 2015 10:29 PM |
| I don't want to move a character.. just a model of bricks. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2015 10:30 PM |
| Look at the part creating.. |
|
|
| Report Abuse |
|
|
Vritix
|
  |
| Joined: 01 Jan 2011 |
| Total Posts: 2790 |
|
|
| 08 Aug 2015 10:32 PM |
I already have the points set :
while true do path = game:GetService("PathfindingService"):ComputeRawPathAsync(game.Workspace.Start.Position,game.Workspace.End.Position,50) points = path:GetPointCoordinates()
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do part = Instance.new("Part") part.FormFactor = Enum.FormFactor.Symmetric part.CanCollide = false part.Size = Vector3.new(1,1,1) part.Position = points[p] part.Anchored = true part.BrickColor = BrickColor.Red() part.Parent = game.Workspace.Points end
wait(0.1) end
I just need to make a model move from start to end. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2015 10:34 PM |
m = DEFINE
while true do path = game:GetService("PathfindingService"):ComputeRawPathAsync(game.Workspace.Start.Position,game.Workspace.End.Position,50) points = path:GetPointCoordinates()
game.Workspace.Points:ClearAllChildren()
for p = 1, #points do local pos = points[p] m:MoveTo(pos) wait() end
wait(0.1) end |
|
|
| Report Abuse |
|
|