For this weeks work I continued to work on my A* path-finding algorithm. I started by reviewing my work from last week to make sure I understood where I was and what I needed to do next. For this week I needed to have the algorithm check what the quickest path was and then have the AI element move across that path. When I began adding the code to check the path I realised that how I was handling the nodes didn't actually work due to the amount of information each node needed to store. I though about different ways I could handle this but couldn't think of any good way of handling this that wouldn't cause me more problems later. After having a look at some resource materials I went back to a YouTube tutorial I looked at when starting my algorithm showing a way to program your own version of A* inside of Unity (Lague, S. 2014). After watching the first 3 videos in this series I noticed the mistake I was making was that I could be storing all the information in a class and then store that into an array. Watching these videos helped give me a much better understanding on what I needed to do next and how I could go about handling it. I went on to use this to help direct me whenever I had a problem while implementing the algorithm.
Once I had the algorithm calculate the path I noticed that the path that was being calculated was very inefficient and instead of going directly to the target position it would go around almost all the other nodes before reaching the target. After a while of debugging and looking back over my research materials I noticed I had mistakenly placed a > instead of a < sign. This meant that the algorithm would pick the least efficient node to move to instead of the most efficient.
Next week I plan to start implementing this into the main AI script and seeing how this compares to using Unity's built in navMesh. Although Unity's navMesh has more features (such as allowing the navMesh agent to jump between navMesh paths) I would like to see how much my own version of A* works. I will also look to see what other things I can add to the algorithm to improve it. Some things that I will be trying to add is support for stairs and generating the node on platforms that are not at the same starting height as the target/player at the start of the game.
References
Lague, S (2014) A* Pathfinding. Available at: https://www.youtube.com/watch?v=-L-WgKMFuhE
No comments:
Post a Comment