Pathfinding AI with changed max jump value

Hello, I’m trying to add to a pathfinding script, a script that does:
1)Let’s NPC jump.
2)Let’s NPC jump if part heigth is inferior to the limit I write.
However, I can’t find how to do it.

You can make your NPC jump with PathfindingService using wayPoint.Action. As for the NPC jump limit, there is a set of parameters in :CreatePath() that you can edit. The radius / height of your NPC make a factor on how your NPC jumps. (you can edit those values btw)

local URadius = 2 -- radius of your NPC
local UHeight = 5 -- height of your NPC


local PFS = game:GetService("PathfindingService")
local unitPath = PFS:CreatePath({URadius, UHeight, true})
unitPath:ComputeAsync( StartPos, EndPos )
local wayPoints = unitPath:GetWaypoints()
for i, v in pairs(wayPoints) do
    Humanoid:MoveTo(v.Position) -- you need to specify the Humanoid here.
    if v.Action == Enum.PathWaypointAction.Jump then
        Unit.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    Unit.Humanoid.MoveToFinished:Wait()
end
2 Likes