Help Pathfinding with imported model full of meshparts

Hi everyone,

I’m trying to use pathfinding on a model made entirely of MeshParts (it’s a pig). I’ve added a HumanoidRootPart in the middle of the pig and a Humanoid because thats what i needed to make it move at all. I just have these core problems with my poathfinding i wanna get into making it do stuff but its being buggy :crying_cat_face:

Issue:

  • My pig did follow the path correctly, but then i broke it somehow but anyways when it did follow it, it doesn’t jump when reaching jump waypoints.
  • I rotated the HumanoidRootPart 180 degrees because the pig would otherwise pathfind backwards. (so Idk if theres a fix for that)
  • All MeshParts are welded to the HumanoidRootPart.

heres the simple script im using

local PathFindingService = game:GetService("PathfindingService")
local pigToMove = game.Workspace:WaitForChild("TestPig")
local humanoid = pigToMove:FindFirstChild("Humanoid")

local goal = game.Workspace:WaitForChild("GoalPart")

local path = PathFindingService:CreatePath({
	AgentCanJump = true,
})

local success, errorMsg = pcall(function()
	path:ComputeAsync(pigToMove.PrimaryPart.Position, goal.Position)
end)

if success then
	for _, waypoint in pairs(path:GetWaypoints()) do
		local part = Instance.new("Part")
		part.Parent = game.Workspace
		part.Material = Enum.Material.Neon
		part.Position = waypoint.Position
		part.CanCollide = false
		part.Anchored = true
		part.Shape = Enum.PartType.Ball

		humanoid:MoveTo(waypoint.Position)

		if waypoint.Action == Enum.PathWaypointAction.Jump then
			humanoid.Jump = true
		end

		humanoid.MoveToFinished:Wait()
	end
else
	warn(errorMsg)
end

My question:
Why isn’t my pig jumping at the jump waypoints?
Could flipping the HumanoidRootPart 180 degrees cause this issue?
Is there a better way to rotate the pig so it faces the right way without messing up physics or pathfinding?


image of the model

video of what its doing:

yes I do have a goal part that is is possible to get to by walking around the walls

Yes, flipping the humanoid root part 180 degrees should in theory fix this problem ( at least it did with me when attempting to recreate the issues )

I wasn’t able to recreate this issue, however I do have a theory. Is the pig getting stuck? If so then the mesh’s probably have can collide on, causing it to get stuck and unable to reach the jump waypoint.

You may also want to turn off CanQuery for the mesh parts so it doesn’t try to path find itself.

i found the issue, for some reason the hipheight wasn’t automatically setting it to the right value, so i just manually set it, and it worked out

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.