Model getting stuck when using PathfindingService

Hello! I’ve been studying PathfindingService tonight and have gained a bit of a knowledge for it. I’ve scripted my “bear” model with this. Script, video example, etc can be viewed below.

Video preview:

Script (ServerScriptService)

local humanoid1 = game.Workspace.Bear.Humanoid
while true do
	path = game:GetService("PathfindingService"):ComputeRawPathAsync(game.Workspace.Start.Position, game.Workspace.End.Position, 200)
	points = path:GetPointCoordinates()
	
	game.Workspace.PathPoints:ClearAllChildren()
	
	for p = 1, #points do		
		humanoid1:MoveTo(points[p])
		humanoid1.MoveToFinished:Wait()
		local parts = humanoid1.Parent:GetChildren()
	end
	wait(.1)
end

Thanks!

1 Like

I don’t know if this means anything, but you’re using PathfindingService’s deprecated functions. You should instead be using PathfindingService:CreatePath, Path:ComputeAsync, and then Path:GetWaypoints. The Path page documents how to use all of these.

1 Like

I don’t think this is a problem, since it was working for a standard dummy earlier… Thanks for the help, though!

1 Like

This might be way off, I haven’t really worked with pathfinding, but do you think the bear is confusing itself with an obstacle? You stated that you used a standard dummy, there might be a difference between using a character/dummy model and a bear model. Again, I might be way off, just trying to help. :slight_smile:

So like, you’re thinking maybe there is an invisible obstacle? I got off for the night, I’ll be checking that tomorrow for sure and getting back to you! Thanks so much!

Not an invisible obstacle per se, but the pathfinding algorithm thinking that the bear is an obstacle, so it can’t go through that path. Now that I think about it, I believe I may be onto something!

Edit: Try making all the parts in the bear CanCollide false temporarily, and then run the game and check if he moves how you intend him to.

Just curious, wouldn’t the bear fall through the baseplate then? I’ll test this out.

Yup, I completely forgot about that, and I stayed up late last night, so I apologize for the late response. :slight_smile:

Alright, that’s fine! :slight_smile:

Hey there! I found that, actually, the bear only goes into the baseplate until the bottom of the HumanoidRootPart! Thanks! (You should see that you were marked as the solution!) :slight_smile: