Connect 2 parts without a gap

Yeah I think you can do that with the use of waypoint spacing. To get it closer and then use some sort of other function.

What I’m using right now are nodes, which the pathfinding module uses A* to find the nearest node closest to the player, and draws a part from the player to that node, then continues to make another part from that node, to the next one, slowly getting to the destination.

Ah, never used nodes before. But can’t you use waypoint spacing in that too? I assume you could.

Well, nodes are basically parts which are welded (connected) together (as an example) which are written into values instead of physical parts.

The system finds the nearest node which is connected (welded) to the current node, this is because if the player is driving on a road, I don’t want it to direct the player offroad as a shortcut on a corner.

I placed the nodes myself instead of using code for it.

Here’s an example of the system.

Here’s the plugin which I used to create the nodes, and an example of how it works.

1 Like

As shown in the plugin video, I created nodes which are connected together. Some are, some aren’t. For example, these are some connected nodes at an intersection.

image

This is what the path would look like once it’s calculated.
image

If I didn’t use nodes, it would look something like this.
image

Can’t you use a costs table in the agent parameters to make the path traverse over more realistic materials like the road?

I’m going to use the same road material on other objects too, and I’m also doing this with dirt paths, which uses the same material as mud.

Ah alright, well then I saw in your code you have something called “pathwidth” maybe you can adjust that?

That just changes the width of the part, not length

It’s currently the width of the roads

Isn’t there a way to space out the parts that you welded? Values*

Yes but there has to be an easier solution other than manually going to every single road and adding 3x the nodes.

Like how the gap filler plugin does it.

Oh yeah then use a plugin sure, so nodes are usually for like small paths I guess? Like let’s say a maze, you know the whole area. But like in let’s say a game like Piggy, the whole map is unpredictable and it would be very time consuming to place each node on such a huge map. So are nodes usually used for like smaller areas?

Well. Nodes can be used for that, but are also used for road GPS systems otherwise normal pathfinding wouldn’t work.

I can’t use a plugin because I’m not making the path manually, I’m making it with code.

Then I think you could adjust these two variables, maybe offset it a bit.

Or this too instead if you don’t want to change the actual goal or start, you can adjust the lerp percentage possibly.

May I also recommend that you use task.wait(.5) as it’s more accurate, and also do a while true do loop instead:

while true do
task.wait(.5) -- Put this at the end
end

Because with your current code you are yielding for no reason at the beginning.

Alright. I also found this devforum post about the same topic but I don’t understand how I can implement it into my code.

I’m getting off so I won’t be able to test things till tomorrow.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.