It was earlier today when I found out about roblox's new pathfinding service perimeters: Wiki Page and I wanted to tinker with it, but being the idiot I am, I could not figure out how. On the wiki page, it says it's a function of "PathfindingService", and "PathfindingService" is a function which you call like this:
local pathfindingService = game:GetService("PathfindingService")
so I was puzzled as to how to implement the new parameters into it. I obviously can't go and do this:
local pathfindingService = game:GetService("PathfindingService","AgentCanJump" = false)
so how would I pass these parameters in?
PathfindingService, as it's name suggests, is a service of Roblox. You retrieve this service by using the :GetService()
function.
local pathfindingService = game:GetService("PathfindingService")
With the above, we can now access the functions that this service provides like :CreatePath()
. This function creates a new path object for us to use and has an optional argument. This argument must be a dictionary with the properties you'd like to set.
--You don't need to put all parameters in this dictionary: local pathParams = { AgentHeight = 5, --default AgentRadius = 3, --default is 2 AgentCanJump = false --default is true }
Available parameters can be seen here.
We can then pass this dictionary into our :CreatePath()
function.
local pathfindingService = game:GetService("PathfindingService") local pathParams = { AgentHeight = 5, AgentRadius = 3, AgentCanJump = false } local newPath = pathfindingService:CreatePath(pathParams)
You now have the ability to use the functions under newPath
since we used :CreatePath()
to make a path object.