Sunday, 26 March 2017

A * improvements

For this weeks work I looked into improving my A* path-finding algorithm. I did this by adding the ability for the algorithm to generate nodes on different Y values so that the AI could path on stairs and platforms at different heights. I also looked into getting the AI to rotate towards where he is walking.

When working on changing on how the nodes generate the first thing I had to look at was how I was going to generate the nodes without adding too much of an impact on the performance of the algorithm. The next thing I did when adding the nodes was set the code to only check nodes that are possible for the AI to get to. This was to stop the AI trying to move to a node that is floating in the scene without a platform below it and stops unnecessary calculations being made. I got this working by checking the location around the node when it is generated to see if it is colliding with it an object. If the node is touching an object it then looks at if that object is possible to be walked on. After implementing this system the AI was still unable to path up or down stairs due to how the nodes were being generated on them. This was being caused by the algorithm picking nodes generated inside the stairs that it couldn't reach. I had a look online and in several books however I couldn't find anything mentioning how I could handle this. I eventually fixed this by adding a unique tag to stair objects so nodes that were touching the stairs had additional checks before they are set active. Once a stair is found it checks the nodes above to see if it is also generating within a step. If the node is touching a stair then the node is disabled as the current node is inside the stairs and if the node above isn't touching the stairs then it should be at the top of a step. After testing this the AI managed to manoeuvre around my scene without having any problems on the stairs/obstacles placed in it.

Next I looked at changing the rotation of the AI. After getting the AIs rotation to translate towards the player the AI worked fine with only a few small problems. These problems happened when walking up stairs and trying to move to nodes at different Y values. I tried stopping the AI from rotating on its Y axis however it continued to do this.

For next week I will be looking to improve the AIs movement so it walks in a smoother path when transitioning between nodes. I will be doing research into some different approaches that I could handle this and deciding on the best approach. I will also look into fixing the bug mentioned earlier with the AI rotating when walking up and down stairs.

No comments:

Post a Comment