Can't get pathfinding to jump

Hello!

Not really sure what to put here but I’m learning about pathfinding and I have this dummy that should move to each waypoint but it doesn’t jump over the gap, not really sure what else to say.

Script:

local replicatedStorage = game:GetService('ReplicatedStorage')
local pathfindingService = game:GetService('PathfindingService')

local modules = replicatedStorage:WaitForChild('Modules')
local tutorialHandler = require(modules:WaitForChild('TutorialHandler'))

local path = pathfindingService:CreatePath(
	{
		['AgentRadius'] = 5;
		['AgentHeight'] = 5;
		['AgentCanJump'] = true;
	}
)

path:ComputeAsync(tutorialHandler.PathWaypoints.Jump[1], tutorialHandler.PathWaypoints.Jump[2]) -- these are just vector3's

while true do
	for i,v in ipairs(path:GetWaypoints()) do
		workspace.Dummy.Humanoid:MoveTo(v.Position)
		workspace.Dummy.Humanoid.MoveToFinished:Wait()
	end
end

Result:

TIA for any help!

1 Like

Alright, to do this, first you’ll have to create a variable referencing the dummies Humanoid then you’ll have to do

If v.Action == Enum.PathwayAction.Jump then Humanoid.Jump == True

Put this inside the I,v ipairs loop.

Tried that and the behaviour seems to be the same. The print(‘jump’) is only outputted when the dummy first goes to the jump, then it’s repeatedly outputted when it falls.

while true do
	for i,v in ipairs(path:GetWaypoints()) do
		workspace.Dummy.Humanoid:MoveTo(v.Position)
		if v.Action == Enum.PathWaypointAction.Jump then workspace.Dummy.Humanoid.Jump = true print('jump') end
		workspace.Dummy.Humanoid.MoveToFinished:Wait()
	end
end

Have you tried to put the computeasync inside of the while true loop? If you do this then the path will keep on updating.

I just tried and the behaviour still seems to be the same.

I don’t think that would be the issue anyway as one path should work properly. I vaguely followed the devhub tutorial, pretty sure it’s only needed when needing to recalculate the path. Since it’s the same V3 arguments, it would return the same path anyway.

What does this line do exactly?

That line creates the path instance which is needed to create the waypoints.

I meant this part sorry,

{
	['AgentRadius'] = 5;
	['AgentHeight'] = 5;
	['AgentCanJump'] = true;
}

Those are the arguments to create the path instance which helps calculate the path waypoints based on the params given. Same sort of thing as TweenInfo or RaycastParams.

Maybe try setting the humanoid’s state once the action is “Jump”.

local replicatedStorage = game:GetService('ReplicatedStorage')
local pathfindingService = game:GetService('PathfindingService')

local modules = replicatedStorage:WaitForChild('Modules')
local tutorialHandler = require(modules:WaitForChild('TutorialHandler'))

local path = pathfindingService:CreatePath(
	{
		['AgentRadius'] = 5;
		['AgentHeight'] = 5;
		['AgentCanJump'] = true;
	}
)

path:ComputeAsync(tutorialHandler.PathWaypoints.Jump[1], tutorialHandler.PathWaypoints.Jump[2]) -- these are just vector3's

while true do
	for i,v in ipairs(path:GetWaypoints()) do
       if v.Action == Enum.PathWaypointAction.Jump then
          workspace.Dummy.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
          print('jumping')
       end

	   workspace.Dummy.Humanoid:MoveTo(v.Position)
	   workspace.Dummy.Humanoid.MoveToFinished:Wait()
   end
end

Mhmh ok, let’s try something, remove those Params for the Create path or comment them out and remove the while true loop, and see what exactly happens.

Tried that out and it seemed to make it better, the dummy is actually jumping but it is jumping into the gap, any solutions for that?

@Painite_Dev, that wouldn’t do anything visually. It would just create the waypoints and nothing else.

I think, maybe adjust the Params on the CreatePath. It should work.