My movement is extremely buggy. The NPC is falling over and walking extremely framey over to the two movement.
Heres a video of the issue:
External MediaI am using pathfinding service, i dont know if thats apart of the issue.
local function MoveToTarget(targetPosition)
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 5,
AgentMaxSlope = 45
})
path:ComputeAsync(Miner.HumanoidRootPart.Position, targetPosition)
if path.Status == Enum.PathStatus.Success then
walkingAnimation:Play()
for _, waypoint in pairs(path:GetWaypoints()) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
local direction = (waypoint.Position - Miner.HumanoidRootPart.Position).unit
local newCFrame = CFrame.new(Miner.HumanoidRootPart.Position, Miner.HumanoidRootPart.Position + direction)
Miner:SetPrimaryPartCFrame(newCFrame)
end
walkingAnimation:Stop()
else
warn("Pathfinding failed!")
end
end
MoveToOreNode = function(node)
local targetPart = node:WaitForChild("Scripted"):WaitForChild("MinerTargetPart")
local isOccupied = node.Scripted.IsOccupied
MoveToTarget(targetPart.Position)
local direction = (targetPart.Position - Miner.HumanoidRootPart.Position).unit
local newCFrame = CFrame.new(Miner.HumanoidRootPart.Position, Miner.HumanoidRootPart.Position + direction)
Miner:SetPrimaryPartCFrame(newCFrame)
end
MoveToDropOff = function()
MoveToTarget(DropOffOrePoint.Position)
end