After fumbling around with the enemy behaviors some more and frustrating myself at their incessant need to run into walls, I decided to take a break from the project and just come back to it in a few weeks. After opening it up the other day, it occurred to me that all of these behaviors could be solved with some rather simple pathfinding, all of which I have implemented before. Basically, I overcomplicated everything by trying to be fancy rather than just going with the simple and straightforward. I thought I’d talk a little my fixes and plans for features, additional content, and soon having a product ready for testing.
The infantry unit is supposed to patrol a set area, like the perimeter of a building. My original idea was that the unit would walk alongside a wall, detect when the wall is gone, and begin to turn until he finds it again. Of course, I never accounted for all of the edge cases, like what happens when a firefight leads the soldier away from the wall, or what if he walks in between two walls (The answer, of course, if that he just stands in place spasming violently). My new and improved solution is to give the soldier a list of coordinates. He moves from one to the next in a game of Connect the Dots, straying from this path only when he comes across an enemy. Once there is nothing to shoot at, he just continues on to the next waypoint. This method does require me to manually enter each Vector3 coordinate , but I feel like that’s not the big of a deal personally.
The other behavior I was having trouble with the helicopter wandering the field. I’m not going to go into the insane scheme that was running through my head, but let’s just say that it certainly wasn’t a high point in my life as far as programming goes. I took one look at the description I wrote for how the helicopter should behave and realized that a basic flocking algorithm covers everything I wanted. So there’s two problems taken care off. Easy solutions that were right in front of me for who knows how long.
With my AI issues solved, I’ll be working on redoing the control scheme for the game next, along with a few little polishing touches for the game. Initially, I had them split between several buttons and touch controls for the unit interaction and moving around the level. Instead, I will use a virtual joystick for moving the camera around the level, and touch controls will handle all of the unit interaction. Once it’s in a solid, functioning state, I will begin looking for testers to get some feedback. I’ll be sticking with 4 units and 3 levels for now. It’s enough to make sure mechanics work as intended, see how clear unit information is presented, and and do some preliminary balance testing.