Im not sure if this is possible without putting barriers but…
How can I make an NPC ignore the grass and only walk on the path its given!?
Here is the script!
local function WalkTo(Position)
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("UpperTorso")
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
AgentMaxStepHeight = 0.5,
AgentAvoidanceEnabled = true,
AvoidanceRadius = 15,
AvoidanceWeight = 10
})
local startPosition = body.Position
local endPosition = Position.Position
path:ComputeAsync(startPosition, endPosition)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
script.Parent.Humanoid:MoveTo(waypoint.Position)
script.Parent.Humanoid.MoveToFinished:Wait()
end
end
If anyone knows how to do this please let me know! I’ve been stuck on this for hours!
I’m not an expert on pathfinding, but it looks like when your WalkTo function is called it collects all the waypoints but isn’t specifying which one of them the NPC is supposed to travel to next.