I dont know what to do, my pathfinding script seems broken and idk why. Script is very basic and I cant believe I did a mistake… anyways here’s the video of my problem: robloxapp-20201215-1230437.wmv (2.3 MB) (dinosaur is spinning around and slowly proggresses to next point)
and here is my script:
wait(5) -- waiting for everything to load
-- some variables --
local service = game:GetService("PathfindingService")
local hum = script.Parent.Humanoid
local torso = script.Parent.Torso
-- just picking a random part and creating path --
local randomPart = game.Workspace.WalkPoints:GetChildren()[math.random(1, #game.Workspace.WalkPoints:GetChildren())]
local path = service:CreatePath()
path:ComputeAsync(torso.Position, randomPart.Position)
local waypoints = path:GetWaypoints()
-- making every waypoint visible for me --
for i, v in pairs(waypoints) do
local part = Instance.new("Part", game.Workspace)
part.Position = v.Position
part.Anchored = true
part.CanCollide = false
end
-- actual pathfinding part --
for i, v in pairs(waypoints) do
hum:MoveTo(v.Position)
if v.Action == Enum.PathWaypointAction.Jump then
hum:ChangeState(Enum.HumanoidStateType.Jumping)
end
hum.MoveToFinished:Wait()
end
so I have a dinosaur, which is spinning while moving between two waypoints and after few spins, makes preogression and go for the next one. (btw u can download urself VLC for phone, for opening video files)
I think I know why, because the you put a part to indicate the waypoints for the Dino to walk, and making it to think that it’s part that you need to jump over. Try removing the parts as indicators.
wait(5)
local PathfindingService = game:GetService("PathfindingService")
local dinosaur = script.Parent -- Your model
local modelSize = dinosaur:GetExtentsSize()
local humanoid = dinosaur.Humanoid
local torso = dinosaur.Torso
local walkPoints = workspace.WalkPoints:GetChildren()
local randomPart = walkPoints[math.random(1, #walkPoints)]
local pathParams = -- If the dinosaur is bigger than a regular humanoid character
{
AgentRadius = modelSize.X;
AgentHight = modelSize.Y;
AgentCanJump = true;
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(torso.Position, randomPart.Position)
local waypoints = path:GetWaypoints()
for _, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Position = waypoint.Position
part.Parent = workspace
end
for _, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
end
comment out the hum.MoveToFinished:Wait()
and see what happens because i think itll be moving to one of the waypoints then returning true and i think you might be finding a new path after the humanoid has reach its location hence the constant change in paths