NoobPath is a Pathfinding module script with Auto Timeout, Non-humanoid support and Waypoint adjustments!
Get it here: NoobPath - Creator Store
Version 1.2
Inspired by SimplePath by Grayzcale
Most Signals/Methods Interchangeable With SimplePath
I suggest checking out SimplePath first
GoodSignal by stravant is used in this module
All the example code assume you have a script inside a Humanoid Rig
local NoobPath = require(PathToNoobPath)
local Guy, JumpDetectConnection = NoobPath.Humanoid(script.Parent, {WaypointSpacing = 10})
-- Parameter 1 is a Character Model, Parameter 2 is AgentParams(Basically settings for pathfinding)
Check Here for Pathfinding basics
Signal Implementation & Partial Demonstration Example:
local NoobPath = require(PathToNoobPath)
local Guy, JumpDetectConnection = NoobPath.Humanoid(script.Parent, {WaypointSpacing = 10, PathSettings = {SupportPartialPath = true})
if Guy.Idle then -- Access Character state through .Idle
print("Idle")
end
Guy.Reached:Connect(function(Waypoint, IsPartial)
print("Reached: " .. tostring(Waypoint) .. " | Partial: " .. tostring(IsPartial))
task.wait(0.1)
Guy:Run()
end)
Guy.WaypointReached:Connect(function(Waypoint, NextWaypoint)
print("WaypointReached: " .. tostring(Waypoint) .. " | NextWaypoint: " .. tostring(NextWaypoint))
Guy:Run()
end)
Guy.Error:Connect(function(ErrorType : string)
print("Error: ".. ErrorType)
task.wait(0.1)
Guy:Run()
end)
Guy.Trapped:Connect(function(TrapType : string)
print("Trapped: ".. TrapType)
if script.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then -- Climbing is slower than usual
Guy.Jump() -- Jump to unstuck
end
Guy:Run()
end)
Guy.Timeout = true -- Off by default, it calculate time necessary to travel between Waypoints and Check if the Character arrived after that amount of time, Trapped will be fired if the Character didn't reach Waypoint in time
Guy.Speed = 16 -- 16 by default, used to allow Timeout calculate time necessary to travel between Waypoints
Guy.Visualize = true -- Off by default, basically generate visual spheres to represent Waypoints
Guy:Run(workspace.SpawnLocation) -- If a Location is given to :Run(), it will be stored and become the default Location to go if there's no argument given
-- Location : Vector3 | BasePart | Model
Loop Implementation Example:
local NoobPath = require(PathToNoobPath)
local Guy,JumpDetectConnection = NoobPath.Humanoid(script.Parent, {WaypointSpacing = 10})
Guy.Visualize = true
while true do
task.wait()
Guy:Run(workspace.SpawnLocation)
end
Non-humanoid Example:
local NoobPath = require(PathToNoobPath)
-- NoobPath.Humanoid() pass in those functions & signals with humanoid defaults
-- There's no JumpDetectConnection as you have to set things up manually
local Guy = NoobPath.new(
script.Parent,
{WaypointSpacing = 10},
function(PositionToGo : Vector3)
-- custom logic to move the Character to PositionToGo
end,
function()
-- custom logic to make the Character Jump
end,
JumpFinishedSignal, -- place a signal here to indicate Finished Jumping, it can be Roblox Signal, BindableEvent.Event, or just use the GoodSignal inside the module
MoveFinishedSignal -- place a signal here to indicate Finished Moving, it can be Roblox Signal, BindableEvent.Event, or just use the GoodSignal inside the module
)
-- Remember to Destroy when not using
local NoobPath = require(PathToNoobPath)
local Guy, JumpDetectConnection = NoobPath.Humanoid(script.Parent, {WaypointSpacing = 10})
-- Do Stuff
Guy:Stop()
-- Do Stuff
JumpDetectConnection:Disconnect()
Guy:Destroy()
Methods & Signals & Variables not demonstrated in the examples are Private