I use an A* algorithm to find a path voiding obstacles. On obtaining the path it would be a good idea to reduce the number of points. Then I would like to typically do a spline interpolation or Bezier Curves to find a smooth path but is it not possible that post smoothening my character bumps into an obstacle? If not possible then why and if it is possible, then how do I avoid it?

  • \$\begingroup\$ Hi, and welcome to Game Development Stack Exchange! Check out our tour to see how we work here. If I understand correctly you're looking for having a smoothed or curved out path based on an A* result that doesn't bump into obstacles, right? \$\endgroup\$ – doppelgreener Jun 2 '17 at 12:47
  • \$\begingroup\$ Yes, that is exactly what i am looking for. But I have a concern that as i smooth it out it might bump into the obstacles since I am thinking of using splines for that purpose \$\endgroup\$ – user254545 Jun 2 '17 at 12:52
  • \$\begingroup\$ Usually A* produces the shortest straight path between obstacles, so there isn't much to "smooth" (it's straight). Are you looking to make the characters take a slightly-less-than-optimal path? It may help to express the situation you're in & what kind of effect you want to create. \$\endgroup\$ – doppelgreener Jun 2 '17 at 12:54
  • \$\begingroup\$ @doppelgreener OP simply means he/she doesn't want the angles beween pathing points to be hard multiples of 45 or 90 degrees, during motion. Splines or Bezier curves would, as rightly suggested, help avoid such artifacts. \$\endgroup\$ – Engineer Jun 2 '17 at 12:55
  • \$\begingroup\$ @ArcaneEngineer They might mean that, but I'm not presuming 45/90 degree turns are even a thing -- like imagine Starcraft, the "shortest path" necessarily involves moving diagonally, close to walls, up to the corners of ramps, etc. \$\endgroup\$ – doppelgreener Jun 2 '17 at 12:56

Do as we all do: play with splines running between adjacent path cells, and see how it works. This is really totally down to personal interpretation. Then adapt your parameters from there. The primary issue is moving around corners. If the curve is too gradual, such that the entity bumps into inner corners during its arc, then strengthen the control point (move it outward) on the outer edge of the arc; this will sharpen the corner to some degree. OTOH, If the curve is too sharp, you're not much better off than where you are at the moment, and you probably need to move the control point back inward.

You can slightly bevel the corners of walls in your game, if all you are worried about is how this looks.

TL;DR Experiment and Adapt. That's a large part of the fun of game development.

  • \$\begingroup\$ Could you edit your answer to add how could i bevel the corners. Thanks \$\endgroup\$ – user254545 Jun 2 '17 at 12:51
  • \$\begingroup\$ @user254545 No, I can't, because that depends entirely on how you build your geometry for the game. You could use Paint, 3DS Max, in-engine voxels, vectors or any of a million other technologies to create your levels and thus to bevel the corners. If you don't know what "beveled corner" means, google it. Then you will understand why I suggested it in this context. \$\endgroup\$ – Engineer Jun 2 '17 at 12:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.