If it was just a plain wall, you could determine very quickly, by visiting a single node, that there is NO way to reach on the other side and then handle it the way you want, possibly still performing an A* and returning the lowest h node. You can now easily know how to navigate on the blue side by going to the edge that will allow you to cross, which is the chicken. is there a way from blue node to red node? Yes! Through the chicken. Now, when you ask for a path from our Hero to the red X, you first do the pathfinding on the high level. How to build this graph you ask? It's easy, simply start from an open node, expand all of its neighbors and add them to a high level node, when you're done, open the dynamic nodes that could lead to another part of the graph and do the same. The arrow represents the edge between the two nodes. First, you want to be able to build a new set of high level nodes and edges that will contain multiple grid nodes (or other representation, wouldn't change a thing)Īs you can see, we now have a right blue node and a left red node. How can you do this? Well, an easy way to do this is to pathfind on hierarchical graphs. Which might be good enough, but if there's any way our little Hero could interact with the chicken to pass, it doesn't make sense at all, what you want is this Using a standard heuristic like manhattan distance or euclidian distance, you will get this result: The walls have colliders AND navmesh obstacles yet the navmesh still generates a path. If they do in fact have colliders and you’re still having issues, you could work around the issue by adding navmesh obstacle components to the walls. We need to think what we want the path to be, since obviously we can't reach it. If the walls don’t have colliders they may not be detected as obstacles. If we set the destination for our Hero on the other side Searching Google, I've found lots of questions on how to dynamically create a nav mesh, but I can't find any information on how to modify one via script. if it's a static obstacle, then going with the lowest h node might be enough, but if it's a dynamic object (like a locked door, draw bridge, etc.) the following examples might help you find out how you want to solve your problem. I've been having fun playing around with Unity and I stumbled on a problem that I can't seem to find an answer for. While the simple answers provided here MIGHT be sufficient enough, I think it depends on your game type and what you're trying to achieve.įor example, take this play field (sorry I'm reusing the same software I used to show you the fog of war :)) :Īs you can see, an Angry Chicken is blocking the path between the left side and the right side.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |