Need help with AI Pathfinding

I have made an NPC that uses pathfinding to get to a block simply called “gohere”

he can jump over blocks, walk around walls simple enough right?

So I made an obby for em.

Take a second to look at that alright? So basically you get the gist of it, the horrifyingly thin block on the top is the waypoint.

image

This is where he goes, he’s just chillin right there.

Is there any way that my bot can find a way to get to that block and climb the trusses?

forgot somethin, heres the script

local PathfindingService = game:GetService("PathfindingService")

local human = script.Parent:WaitForChild(“Humanoid”)
local torso = script.Parent:WaitForChild(“Torso”)

local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.Position, game.Workspace.gohere.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump
then human:ChangeState (Enum.HumanoidStateType.Jumping)

end



human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait(5)
end

human:MoveTo(game.Workspace.gohere.Position)

1 Like

I think you shall use rays to detect these because if it’s unreachable with a jump or direct walking, Pathfinding won’t be enough.

I wouldn’t bet on using Torso as a variable, instead use HumanoidRootPart.

Also, I would set parameters to the Width, Height of the NPC and to check if the NPC can jump, like so:

local parameters = {
["Height"] = 6;
["Width"] = 2;
["Jump"] = true
}
1 Like