I'm working on a sidescrolling game with an underwater "fish-like" AI that has some goals (interacting at various locations) and things to avoid (player).

  1. Started of with a Navmesh and simple straight line navigation but since algos like A* always take the shortest path what ends up happening just doesn't look good.

Straight line navigation

  1. To solve this, I thought I could add some random area penalties to the navigation nodes (currently a grid). I generated these penalties using perlin noise, which did curve the path, but the effect is very minor, because again A* does not like to deviate from a straight line even with big penalties. If you make them too big, it's gonna act like obstacles, which isn't very usable either.

Noise penalties

  1. So the question is - how do I achieve something like this?

The dream


  • 1
    \$\begingroup\$ I am not sure if NavMesh is the way to go then (in it's out of the box state). Did you try to add more than just one position, instead of going from start to end, keep multiple points (like an array of points) that your fish has to visit before it gets to it's final (original) desination? In that case you could try to manipulate how those points in between have to be chosen, then let NavMesh handle the actual pathfinding (which will still be a shortest path towards those points). Just an idea, hence a comment. You make the curves in this case, not NavMesh, but it still navigates for you. \$\endgroup\$
    – D.Kallan
    Jan 7 at 11:43
  • 1
    \$\begingroup\$ D.Kallan idea is good. You could create points between objects where the fish as to go before reaching the destination. You could just get the middle of the 2 objects location (and add random variations ?). Else, you could generate a region around the object that the fish would have to avoid as much as possible, so it would do more of a curve. Instead of just adding circular zone, you could use perlin noise to generate them with more complex patterns. \$\endgroup\$ Jan 7 at 14:02
  • 1
    \$\begingroup\$ From the images, looks like you want to model inertia - something like chapter 2.4 from AI from Game Developers. \$\endgroup\$
    – Russell
    Jan 7 at 19:51
  • \$\begingroup\$ Can you include an image of the noise you used to generate the altered paths? \$\endgroup\$
    – Pikalek
    Jan 8 at 5:10
  • \$\begingroup\$ You might also be interested in "How to force a sub-optimal path" \$\endgroup\$
    – DMGregory
    Jan 9 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.