I'm developing top-down rpg game and got some problems using https://libgdx.badlogicgames.com/gdx-ai/docs/com/badlogic/gdx/ai/steer/behaviors/FollowPath.html

I have a path (picture 1), in this case 2 points - corner and target. path
Then I try to make the character move (passing my path to libgdx FollowPath Steering Behavior).

private FollowPath<Vector2, LinePathParam> followp= new FollowPath<Vector2, LinePathParam>(this, new LinePath<Vector2>(astar.findPath(position, target)),0f,0f);

(astar.findPath(position, target) - function that returns Array of points(path). Experimenting with 3rd and 4th parameters (passOffset and predictionTime) made it worse.) And it gains such result (purple line on Picture 2).

enter image description here
But how can I get such result (green line on Picture 3)? enter image description here

  • \$\begingroup\$ What result do you get when you use the default constructor? FollowPath(Steerable<T> owner, Path<T,P> path) What kind of graph do you use? Are you sure the returned path is correct? \$\endgroup\$
    – nathan
    Oct 6, 2015 at 8:36
  • \$\begingroup\$ @nathan, default constructor - same result. Path is correct. Kind of graph... what do you mean? \$\endgroup\$ Oct 6, 2015 at 10:31

1 Answer 1



I posted an example scenario answer on the linked post but I thought that maybe I should provide a more direct answer on this page.

So, as you can see, the green line seems to bend toward the normal then bend away again toward the final position. To do this, we can use two LibGDX Circle instances with the same radii - being large enough for the first point at the turn's edge to be where you want the turning to start.

So now we have two points with two radii, now what? Well, we check when the entity reaches the center of the circle and then makes a small delay of around half a second. After this delay, the line will start to bend towards the vertical normal line and will move simultaneously.

Eventually, it will reach the normal and stop bending but then it will reach the edge of the second circle that surrounds the end point. As it reaches this point, it will again have a small delay of around a quarter of a second then start to bend toward the end point and again move simultaneously. After reaching the correct angle it will continue to move in that direction till it reaches the point.

Well, I've talked about moving on an angle but how do we achieve this? Simple really, (I'm in 9th grade / Year 10 and I know this) we use the equation of the line or y=m*x+c in which y represents the Y coordinate on the screen depending on the gradient m and starting at the intercept c but this is basic straight-line graph calculus and this has 2 turns. Assuming we go by the calculus rules of dimensional naming conventions, 1D = straight-line, 2D = quadratic, 3D = cubic etc., then this would be a cubic function graph since there are 3 different line equations but to do cubic function graphs. I'm not sure of those but here's a link: Click me!

Hope this helps!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .