#Pathfinding running into walls
9 messages · Page 1 of 1 (latest)
the green spheres are waypoints that it generated btw
and as you could see in the image the are placed like the wall isnt there
does the wall have a collisiongroup?
no
by no I meant I never touched it, its set to default
local PFS = game:GetService("PathfindingService")
local MovementArea = workspace.house.MovementArea
local path = PFS:CreatePath({
AgentRadius = 6,
AgentHeight = 5, -- Ensure correct agent height
AgentCanJump = false,
AgentCanClimb = false
})
local humanoid = script.Parent:FindFirstChildOfClass("Humanoid")
local humanoidRoot = script.Parent:FindFirstChild("HumanoidRootPart")
local function followPath(destination)
-- Compute the path
local success, errorMessage = pcall(function()
path:ComputeAsync(humanoidRoot.Position, destination)
end)
if success and path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
local nextWaypointIndex = 2
-- Move through waypoints
for _, point in ipairs(waypoints) do
if point.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
humanoid:MoveTo(point.Position)
humanoid.MoveToFinished:Wait()
end
else
warn("Path not computed!", errorMessage)
end
end
while true do
wait(math.random(5, 10))
-- Pick a random point inside MovementArea
local X = math.random(-MovementArea.Size.X/2, MovementArea.Size.X/2)
local Z = math.random(-MovementArea.Size.Z/2, MovementArea.Size.Z/2)
local destination = MovementArea.Position + Vector3.new(X, 0, Z)
-- Compute a test path to see if it's reachable
local testPath = PFS:CreatePath({ AgentRadius = 6, AgentCanJump = false })
testPath:ComputeAsync(humanoidRoot.Position, destination)
if testPath.Status == Enum.PathStatus.Success then
followPath(destination)
else
warn("Invalid path, choosing a new point.")
end
end
try this
I actually figured out the issue, the wall in between was a union which I wouldnt believe would be an issue but it worked once I changed the wall for a normal part
Collision fidelity issue maybe?