You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want the ai to be able to traverse small spaces and recognize its own height
-
What is the issue? The ai just puts markers above the small obstacles blocking the ai instead of pathfinding around said obstacles
-
What solutions have you tried so far? I have tried changing the hip height and the safe radius around the ai but it still just path finds above (yes jumping is off too)
I dont exactly wanna use material costs but even those dont work either so is there any way to alert the ai of its height properly?
local PathfindingService = game:GetService("PathfindingService")
--local Players = game:GetService("Players")
--local player = Players.LocalPlayer
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local TEST_DESTINATION = game.Workspace.PathfindPart.Position
local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection
local function followPath(destination)
--while true do
local destination = game.Workspace.PathfindPart.Position
local path = PathfindingService:CreatePath({
AgentRadius = 0,
AgentHeight = 0.4,
AgentCanJump = false,
WaypointSpacing = 0.6,
Costs = {
Cobblestone = 20,
Fabric = 20,
}
})
local success, errorMessage = pcall(function()
path:ComputeAsync(character.PrimaryPart.Position, destination)
end)
if success and path.Status == Enum.PathStatus.Success then
-- Get the path waypoints
waypoints = path:GetWaypoints()
for i, v in pairs(waypoints) do
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Anchored = true
Part.Size = Vector3.new(0.25, 0.25, 0.25)
Part.Position = v.Position
Part.CanCollide = false
end
-- Detect if path becomes blocked
for _, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end
else
-- reachedConnection:Disconnect()
--blockedConnection:Disconnect()
end
-- Detect when movement to next waypoint is complete
end
followPath(TEST_DESTINATION)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.