Pathfinding Service AI takes too sharp of turns

So im trying to make an AI, but the movement looks so weirdly unnatural with it just snapping at 90 degree angles around corners.

(code)

local function patrol(moveTo)
		if moveTo then
			local destination = moveTo
			local path = pathfinding:CreatePath({AgentRadius = 4})
			path:ComputeAsync(rootPart.Position,destination.Position)

			local waypoints = path:GetWaypoints()

			for i,v in pairs(waypoints) do
				humanoid:MoveTo(v.Position)
				if v.Action == Enum.PathWaypointAction.Jump then
					humanoid.Jump = true
				end
				humanoid.MoveToFinished:Wait()
			end
		else
			local destinations = workspace.Patrol:GetChildren()
			local destination = destinations[math.random(1,#destinations)]
		local path = pathfinding:CreatePath({AgentRadius = 10})
			path:ComputeAsync(rootPart.Position,destination.Position)

			local waypoints = path:GetWaypoints()

		for i,v in pairs(waypoints) do
			if patroling then
				humanoid:MoveTo(v.Position)
				if v.Action == Enum.PathWaypointAction.Jump then
					humanoid.Jump = true
				end
				humanoid.MoveToFinished:Wait()
			end
		end
	end
end

if you know any workarounds to make turning smoother for pathfinding, please tell me.

1 Like

You mean something like this, right?

imagen

The NPC it’s doing that because you specified it on the agent parameters, increasing the AgentRadius should solve it. If not, you will need to make your own AI

Edit: if I did misunderstand your problem, reply me with a image/gif/video, please :slight_smile:


this is what i mean, and ill mess with AgentRadius and see

nevermind, agentradius just moves it from the wall
image

Ah, sadly you will need to make your own AI to fix that issue as Roblox does not offer any parameters for making it smooth :frowning_face:

ah, that sucks

im sure theres some way to use CFrames to make a curved corner instead of just a straight shot, ill get that figured out. thanks for the help

1 Like

Wait! You can use Bezier curves to make it smooth, I totally forgot it! with some magics, you could get the point that it’s near to the curve start and then you can make the bezier curve to make a smooth turn.

1 Like

I can’t provide an example right now but it’s possible Bézier Curves | Roblox Creator Documentation @Jamstoe

1 Like

just figured that out, reading about it here: Bézier Curves | Roblox Creator Documentation

edit: yep that works out amazingly, just gotta make it added into the pathfinding script, got a part moving smoothly between 3 parts

2 Likes

2 Likes