Hullo, I am working on a ‘miner’ ai which goes to the nearest ore and then mines it, I am currently struggling with how I would make the ai pathfind to a position just behind the ore.
Currently the ai just sits on top of the ore and that isn’t very helpful to me.
local function walkToOre()
local path = PathfindingService:CreatePath()
local success, errorMessage = pcall(function()
--path:ComputeAsync(humrp.Position, workspace.FrontOfFactory.Position + Vector3.new(math.random(1,10),math.random(1,10),math.random(1,10)))
path:ComputeAsync(humrp.Position, getNearestOre().Main.Position) -- this is the part of the script that I need to change
end)
WalkAnim:Play()
if success and path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _,waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
hum:ChangeState(Enum.HumanoidStateType.Jumping)
end
if getNearestOre() then
breakOre()
end
hum:MoveTo(waypoint.Position)
hum.MoveToFinished:Wait()
end
end
WalkAnim:Stop()
while task.wait(0.5) do
walkToOre()
end
end
walkToOre()
path:ComputeAsync(humrp.Position, getNearestOre().Main.Position)
this the part I need to change, Main.Position is the centre of the ore.