Okay, I’ll be direct. I’m making an NPC that with each “RunService.Heartbeat” calculates a path to a specific point, but when there is an obstacle where it needs to jump, it jumps… But it gets stuck there, I’ve looked in several videos and posts and even I viewed some codes, but nothing helped, can anyone help me?
robloxapp-20240511-2318270.wmv (653,6,KB)
Agent Parameters:
ai.PathParams = {
AgentRadius = 2.65,
AgentHeight = 5,
AgentCanJump = true,
AgentCanClimb = true,
WaypointSpacing = math.huge,
Costs = {
-- PathModifiers --
Danger = math.huge,
-- Materials --
Water = 20,
-- Actions --
Climb = 4
}
}
Base code:
local ai = require(script.Parent)
local human = ai.Humanoid
local hrp = ai.HumanoidRootPart
local target = ai.Target
local path = ai.PathfindingService:CreatePath(ai.PathParams)
local waypoints = {}
ai.RunService.Heartbeat:Connect(function()
if target.Value and target.Value:IsA("BasePart") then
path:ComputeAsync(hrp.Position - Vector3.new(0, hrp.Size.Y/0.75, 0), target.Value.Position)
if path.Status == Enum.PathStatus.Success then
waypoints = path:GetWaypoints()
table.remove(waypoints, 1)
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait()
end
else
return
end
end
end)