3
\$\begingroup\$

I am developing a game in Unity3D. I want an enemy character to follow the player around. The problem is, my surface is uneven and full of mountains. I am using aarongranberg's pathfinding project. Every time that a player climbs a hill or a mountain, the enemy stops because the grid is flat and it considers the mountain to be an obstacle. How do I solve this problem ?

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Don't make mountains an obstacle, just give them a higher cost than flat land... \$\endgroup\$ Aug 29, 2014 at 17:41
  • \$\begingroup\$ How do i do that ? \$\endgroup\$ Aug 29, 2014 at 17:53
  • 4
    \$\begingroup\$ Read the instructions on how to use your pathfinding library? Setting path-costs is a basic prerequisite for using A* on a graph. \$\endgroup\$ Aug 29, 2014 at 18:01
  • \$\begingroup\$ Maybe post an answer of how you solved your specific problem afterwards and accept it. \$\endgroup\$
    – JFBM
    Aug 29, 2014 at 21:50
  • \$\begingroup\$ I will as soon as I finish finding it. \$\endgroup\$ Aug 29, 2014 at 22:42

2 Answers 2

1
\$\begingroup\$

Essentialy A* needs to be configured with what is not an accessible tile , so you can configure that by making an algorithm using gameObjects 'surface taken on the terrain then calculate the tiles to avoid at runtime .Then add it to the closed list (if there is not something for that already )

\$\endgroup\$
0
\$\begingroup\$

Within this project, you are able to define what is passable and impassable terrain. If you recast the graph and alter the maximum slope that's walkable to the gradient of your mountains, they should be included in the navmesh, albeit at a higher cost to use.

There may be other ways, but ultimately, what you want to be looking to do is include the mountain in the mesh as a highly weighted path. I'd recommend reading through the documentation for your A* project

\$\endgroup\$

You must log in to answer this question.

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