How to force waypoint spacing? (PathFindingService)

How do i make it so that when I use path finding service the waypoints will have exact same spacing? I know that there are Agent Parameters that lets you change the waypoint spacing but for some reason it doesn’t work.

local path = PFS:CreatePath({
		["AgentCanJump"] = false,
		["WayPointSpacing"] = 3,
	})
	path:ComputeAsync(testPart.Position, base.Position)
	
	local wayPoints = path:GetWaypoints()
	
	for i,waypoint in pairs(wayPoints) do
--rest of the code

For some reason the waypoint spacing are still off.

So in PathfindingService:CreatePath, it says WaypointSpacing, which is not when you have.

1 Like

Wow, that was a really stupid mistake. My fault.


Even then, sometimes it will come up with close points on corners, but never larger than the specified distance.

I was just about to ask how do I fix those?

I don’t think you are supposed to. When you loop through the waypoints you should instantly continue on as soon as the waypoint is reached.

I’m using Tween Service to move the character (client sided rendering), I’m guessing

if distance < 2 then
    continue 
end

will solve the problem?

Well since the character is client-sided, it should replicate no problem.
I think Humanoid:Move and Humanoid:MoveTo are traditionally used for following a path.

See Character pathfinding | Documentation - Roblox Creator Hub for an example.

I dont quite understand what you mean by “since the character is client-sided, it should replicate no problem.”

Yes humanoid:MoveTo() are usually used with pathfinding, but since my game is client side rendered, the server doesn’t have a character. So instead i use a part and tween the part with pathfinding.

The Distance between waypoints divided by the speed of the character is the time it will take to reach said waypoint (distance/speed = time). You can use that in the TweenInfo and either task.wait(time) or Tween.Completed:Wait() to wait on the tween to complete.

By default, characters are created on the server and updates to the HumanoidRootPart are sent from the cleint to the server and then to other clients. In other words it’s client-owned. This is why character teleport exploits are so common. The client has nearly full control over their own character. This was compromised for quicker character reaction.

Yes I’m using distance/speed to get the tween time. I still dont quite understand the last part you were saying. Is my method a bad or a good thing?

No your solution is likely fine.

1 Like