Edit: silly me. I just remembered that you can adjust the pathfinder grid size. That would reduce the jagged lines. I can’t believe I didn’t think of that. Although, I’m glad that I learned about the Chaikin curves method. So, there’s that.
Edit #2. Now, I’m not sure if the Nav Mesh behavior let’s you adjust the grid size like the built-in pathfinder.
Edit #3: You can change the grid size using an action of the obstacle although for some reason the action is set to private. I made the action public but it didn’t change much. It actually made it tougher to find a path. There are 2 things that create a smoother path. The grid size and the collision mask of the obstacle. The more detailed the mask, the smooth the path.
Not sure why they made these settings private. They are in the documentation.
My most recent method doesn’t use physics. I uses the nav mesh pathfinder. I just played around with it to try to smooth the curve.
I found out about the Chaikin curves method. It’s fairly simple. Using lerp, you replace the nodes by nodes that are at .25 and .75 along each segment.
This is the new versus the old.
Variables
I used an array because it helped me understand the process. It could probably be rewritten without the array but it would still take additional variables like a structure to hold the last node.
The triangle body has the nav mesh pathfinder behavior. It could be hidden and placed at the tip of a visual object. The smaller the pathfinder object, the close you can get to the obstacle.
The large circle has the nav mesh pathfinder obstacle behavior.
The head is the small object. It has the drag behavior for testing. It’s just used as a target.
I guess if there were hidden obstacles, it would force the start and end to follow a path or direction.
The maximum length of the line can be controlled by either the distance from the head to the body or actually calculate the distance by adding the distance of the individual segments. That would be more difficult but it would give a true distance.