Superhero Project

Superhero Project

This is a personal project that I've been working on in Unity to learn about programming AI and first-person platformers. It's still a work in progress, so I'll be updating this page as I add more to the project!

First is some discussion on the AI of the game, and next time I'll be talking about the platforming.

Enemy AI

This is my first time doing any sort of enemy AI programming, so I just dove head first into it. The enemies (white capsules with stylish black sunglasses) can follow the player using Unity's built-in Navmesh function, jumping up, down, and between buildings using off-mesh links. They have 3 states: idle, chase, and flank/attack. 

The enemies start out in their idle state, but if the player walks into their field of vision and within 30 units (seeing), or just within 10 units (hearing), the enemy finds the player and starts chasing. 

If the enemy is far enough away from the player while chasing, they leap forward. This gets the enemy closer to the player and it also just looks really cool to see a whole bunch of enemies leaping through the air towards you!

If the enemy gets within a certain distance of the player, they attempt to hone in. They send out a raycast toward the player and if they have a clear path, they continue to move forward. When they're close enough, the enemy will punch the player. If, when the enemy sends out it's raycast, another enemy is blocking the path to the player, the enemy will jump over the player, in an attempt to flank. The enemy jumps forward and a random amount to the side. This way the enemies can jump straight behind the player, or to the sides, creating a variety of flanking opportunities. 

Why It's Good

I never really seem to have that issue of "I can just walk backwards and they all follow me in a line". The enemies always try to surround me, which I think is pretty cool. 

It looks really cool when I have several enemies leaping towards me. I really like seeing that a lot. This is a superhero project, and I think the leaping enemies makes it feel more like that.

Why It's Bad

I'm using a ground detection system that is based on the one Unity uses for their first-person controller. It's not really great, though, so I get a lot of enemies freezing in the air when they bump into stuff and think that they've landed on the ground. One of the next steps is to make the ground detection a little more operational.

Also, sometimes things can get a bit claustrophobic. I like that the enemies can surround me, but sometimes I feel like I'm being hit around like a pinball machine. I want to add in more things that the enemies can do, like maybe hold back when there's more than a couple enemies attacking, or a cool wall grab maneuver.