i am trying to make an pathfinding npc but this is what i see if i put a normal sized torso it avoids walls but when i make the torso a bit bigger it seems to not avoid the wall
My code for roblox pathfinding:
local pathfindingService = game:GetService("PathfindingService")
local humanoid = script.Parent.Humanoid
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("Torso")
local destination = game.Workspace.Destination.Position
local path = pathfindingService:CreatePath()
path:ComputeAsync(body.Position, destination)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
end

1 comment
you are calculating based on the bodies position, not the size. Roblox's path finding service usually accounts for this I recommend using that. If you want to full account for size then use raycasting. You can also disable collisions for the wall and let the body move through it.