I 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
While its likely an issue with the miner’s model or animations, I’d suggest using Humanoid:MoveTo() in any case that the Agent has line of sight of the object.
Otherwise, I’d consider checking your model. Did you add any parts with collisions on?
local direction = (waypoint.Position - Miner.HumanoidRootPart.Position).unit
local newCFrame = CFrame.new(Miner.HumanoidRootPart.Position, Miner.HumanoidRootPart.Position + direction)
Miner:SetPrimaryPartCFrame(newCFrame)
Try removing this line as well, as this might cause positioning problems.
You also repeat this line twice.
Otherwise, it’s good to comment out certain parts and see if it fixes your problem. Mark out the animations, this might cause a collision issue as I said. Try removing the primarypartCFrame, see if this is moving your model strangely. Worst comes to worst, none of these are issues, you simply add them back.
ive implemented this and he no longer falls down, but still walks very framey and teleporty, is there way to fix it? Ive edited out portions of the code and cannot fix it.
Did you remove the code that literally teleports him? If so, then issues regarding teleportation could be related to a large number of waypoints or strange calculation.
If its very mild teleportation, I’d just attribute it to lag.
If its noticeable, then ensure you deleted ALL lines of code that teleport (you previously had two that did the same thing) and perhaps mess around with walkspeed so you can better analyze the problem (see how often teleportation occurs)
ive done a little bit of bug fixing on my own, and just ended up using humanoid:moveto instead of what i was using before. It works like a charm. Thank you so much