Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to implement the new path finding service parameters?

Asked by 5 years ago
Edited by User#24403 5 years ago

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?

1 answer

Log in to vote
1
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

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.

Let me know if you need something explained or if I had missed anything.

References:

Ad

Answer this question