Hello,
I’m writing an AI Script for my NPC. I want it to be able to climb stairs. But it doesn’t. It just goes to the wall and gets stuck, it’s not smart enough to climb stairs.
Script:
local npc = script.Parent
local humanoid = npc.Humanoid
npc.PrimaryPart:SetNetworkOwner(nil)
local function getPath(destination)
local PathfindingService = game:GetService("PathfindingService")
local pathParams = {
["AgentHeight"] = 2,
["AgentRadius"] = 5,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(npc.HumanoidRootPart.Position, destination.Position)
return path
end
local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
else
humanoid:MoveTo(destination.Position - (npc.HumanoidRootPart.CFrame.LookVector * 10))
end
end
function patrol()
local waypoints = workspace.Waypoints:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
while wait(math.random(6,12)) do
patrol()
end
How would I make it go up stairs?