I'm having a problem with AI movement in my top-down game. AI builds path and than moves using libgdx FollowPath (this problem is still actual) steering behavior. I have some solutions, but can't guess whitch is better(or I even need other solution). FollowPath params:

followp = new FollowPath<Vector2, LinePathParam>(this,
            new LinePath<Vector2>(path));

Problem. Character doesn't move straightly according to the path - cuts corners through obstacles. Solution 1. Find right proportion between character speed/acceleration, character size, obstacles size. Curent parameters: maxLinearSpeed = 100; maxLinearAcceleration = 150; maxAngularSpeed = 15; maxAngularAcceleration = 30; characterRadius=40; obstacleSize=120 (width and height). But if acceleration and speed are too big, character will move like "on rails" and even sticks on corners. Too small - character will be skidding.

Solution 2. Write own FollowPath steering behavior, whitch requires character to get close enough to every point of the path (without using predictionTime,that prevents sticking, but allows cutting corners) and using Arrive on every point of the path, that won't allow skidding.

Solution 3. Use RaycastObstacleAvoidance with FollowPath together(Priority steering). Here comes another problem: cause of raycasting character shakes (especially when it needs to turn around near wall or just target is near wall). Probably, it is solved by usage of lower angular acceleration (causes skidding).


1 Answer 1


Example Solution - Car Game

We have our map and on each of the corners of said map, there is a small circle and a turning angle. The AI will check if the car's collision box is within this circle; it will have a small delay then gradually turn the car towards the turning angle of the corner. Depending on the difficulty these variables will be changed (High = Small delays, Faster turning toward angle etc.).

This will allow for the AI to be able to turn single corners but now what if the road forks and there are 2 possible directions, the car would only be able to go in one allowing the player relatively easy driving as they will have one empty road. Here there are multiple solutions but here are 2 that I've thought of:

  • The circle will be paired with the number of forks instead and each time a car reaches the circle, a random number will be generated and depending on this number, the car will turn toward that turn using the aforementioned method.
  • You could have an array of angles that each of the turns has. Whenever the car reaches the point, it finds the distance between the car's current bearing and the angle in which the turn is and whichever is shortest is picked by the AI and the car will turn toward it.

Sorry for the lack of detail, written in a hurry but I hope it helps! ~ Ammar T

  • \$\begingroup\$ So, you mean adding circles to every corner of every obstacle and using gamedevelopment.tutsplus.com/tutorials/… \$\endgroup\$ Commented Dec 19, 2015 at 17:11
  • \$\begingroup\$ Yes, the solutions presented are very similar to the ones on the site :) \$\endgroup\$ Commented Dec 19, 2015 at 17:12

You must log in to answer this question.

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