My ai wont jump to reach the position it pathfinds to. Even if it is blocked by a wall.
Script:
local PathfindingService = game:GetService("PathfindingService")
local pathParams = {
AgentHeight = 3, --default is 5
AgentRadius = 2.3, --default is 2
AgentCanJump = true --default is true
}
function PathFind(Humanoid,Hit,root)
local RootPart = Humanoid.Parent:FindFirstChild("HumanoidRootPart")
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(RootPart.Position, Hit)
local waypoints = path:GetWaypoints()
path.Blocked:Connect(function()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)
for i = 1,#waypoints do
if waypoints[i].Action == Enum.PathWaypointAction.Jump then
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
wait()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
Humanoid:MoveTo(waypoints[i].Position)
wait(0.2)
end
end
It could be that the AI is computing a path assuming it’s a normal-sized humanoid. Your small model might not be able to get over that obstacle without jumping, but a normal-sized humanoid would.
Jumping is tricky, because it uses physics to determine when to jump. If physics thinks you can walk, but your hip height is too low, you collide with the step, for example. If it doesn’t think you can make the jump, it’s a wall. You might try different heights and distances along with different jump power to see if you can get the model to jump at the right place.
Apart from tricking the system, you may have to write your own. I did, and it’s not great either.
I tried to make a script so it detects heights. But that didn’t work. It gave me nil. Anyway thanks for the help. Also, I tried to use path.Blocked, but it didn’t work still.