My NPC pathfind AI is failing to jump over deadly obstacles

I have made a small 2 lava jump obby test course for an npc that I put together with a pathfinding script I made. Problem is that it despite setting neon as one of the costs in the createpath table (which is the material used for the jumps), it seems that it fails at every attempt to get to the set goal position whether it’s by jumping too early, not at all or just straight up going off the course path entirely (they can’t get back onto it afterwards) and falling off. I’ve tried resizing the parts to just one stud wide instead of the two I began with and even substituted the math.huge value for the cost of the neon material in the script for 10 and it continues to do this.
For reference:

local pathservice = game:GetService("PathfindingService")

local humanoid = script.Parent.Humanoid
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("Torso")
local destination = workspace.PathMap.Goal.Position

local path = pathservice:CreatePath({
	AgentRadius = 4, -- comma seperation in table
	AgentHeight = 5.5,
	Costs = {
		Neon = 10
	}
	
})

path:ComputeAsync(body.Position, destination)

local waypoints = path:GetWaypoints()


-- iterate through waypoints and jump when needed
for i, waypoint in pairs(waypoints) do
	humanoid:MoveTo(waypoint.Position)
	
	if waypoint.Action == Enum.PathWaypointAction.Jump then
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	
	humanoid.MoveToFinished:Wait()
end

I just need the NPC to jump over the lava parts (red neon parts in snippet) without dying so that it can reach the goal at the end. How can I fix this?

1 Like

You should code your NPC to specifically avoid those objects. Name your object obstacle 1 and use the script it to avoid the obstacle. Unfortunately, Artificial Intelligence in Roblox is not strong enough to detect obstacles yet. You can also use animations, which show that the NPC jumps over every obstacle. This is a lot easier to do and less time taking, it might be the only smoothest process you can do right now.
Make sure your NPC is properly rigged. You can get a few animations (R6 and R15) from the toolbox for free if you are not willing to make them yourselves. But you should know the basics of animating. For the smooth flow of keyframes I recommend using Moon Animator:

Regards,
Ignitice

Unfortunately, you can’t use PathfindingModifiers to tell the NPC jump over certain parts. You’d have to use another way to make the NPC jump if you don’t want it to walk away the death brick.

If only npc will gonna do that obstacle you can make optic illusion like this:

Robloxs pathfinding is bad at this but you get the idea
You need to CanCollide = false and CanQuery = false parts near kill parts
and better placement not like me

1 Like