Path Finding Service Ignoring Parts

I’ve made a path finding system but for some reason it’s ignoring some of parts so the pet goes through the part instead of walking on top of it.

Not working for this part
https://gyazo.com/6b7aaeb850beb85b42ef887a53e935a0

Working for these parts
https://gyazo.com/20028879c02fce8d566ed91a9f0e036c

How could I fix this, as it completely ruins the system. Thank you.

3 Likes

So when I have the part like this it works fine
https://gyazo.com/74d4d6902ab16bc0510d2cb7309dc26a
But when I rotate it 90 degrees it doesn’t work
https://gyazo.com/143f350beade84c382168f74e1346ea6

I don’t really understand whats the Problem , in the Video it seems like the pets moves with you.

When it computes the path it doesn’t sense that there is a part, so the waypoint is in the part making the pet glide through the part like a ghost instead of going on top of it. The white balls represent the waypoints.

Would you mind giving your code? So I can experiment it and tell you how you can fix it

1 Like
local PathfindingService = game:GetService("PathfindingService")

local waypoints

local function followPath(destinationObject, path, HRP)
	-- Compute and check the path
	path:ComputeAsync(Pet.Sphere.Position, destinationObject.Position)
	-- Empty waypoints table after each new path coputation
	waypoints = {}
	
	if path.Status == Enum.PathStatus.Success then
		-- Get the path waypoints and start pet walking
		waypoints = path:GetWaypoints()
		
		for _, waypoint in pairs(waypoints) do
			local part = Instance.new("Part")
			part.Shape = "Ball"
			part.Material = "Neon"
			part.Size = Vector3.new(1,1,1)
			part.Position = waypoint.Position
			part.Anchored = true
			part.CanCollide = false
			part.Parent = game.Workspace
		end
		
		for _, waypoint in pairs(waypoints) do
			local propertyTable = {
				Position = waypoint.Position  + (Vector3.new(0,0.7,0)) --+ (Vector3.new(humanoid.Size))
			}
			local tween = tweenService:Create(Pet.Sphere.BodyPosition, tweeningInformation, propertyTable)
			
			tween:Play()
		end
		Pet.Sphere.BodyGyro.CFrame = CFrame.new(Pet.Sphere.Position, HRP.Position)
	end
		
end		

while true do
	local Character = plr
	local HRP = Character:WaitForChild('HumanoidRootPart')
	local CurrentPosition = HRP.Position
	local DistanceTravelled = (CurrentPosition - LastPosition).Magnitude
	if DistanceTravelled >= 4 and DistanceTravelled <= 50 then
		local destination = HRP.CFrame:ToWorldSpace(CFrame.new(-3,0,0))--define the destination
		LastPosition = CurrentPosition
		local path = PathfindingService:CreatePath()--Create a path
		followPath(destination, path, HRP)

I took out parts of the code that don’t have to do with pathfinding to make it shorter.

Found an okay fix. No need to experiment with my code anymore, thanks for trying to help though!

Oh sorry for not being of any use , my internet was so bad that I couldn’t even try the code , really sorry :pensive: .

1 Like

Hi!, can you help me? I have the exact same problem, but with the entire map, the NPC goes straight to the point, and ignores the parts of the map, except the terrain. pls help me!