C++ | Platformer | AI | Pipeline
Blight was the third project at the Game Assembly, also using The Game Assemblies Tga2D home engine. The projects reference game was no surprise, Limbo. As we needed physics for the game, we implemented Box2D as our physics engine.
A girl wakes up from a crash, with her past forgotten. Something is not right...
I did some pipeline programming from Unity to Tga2D and I did the AI for the game. I also created a wrapper for raycasting with Box2D Engine, as I find creating AI with raycasting helps a lot. Actually, raycasting everything helps a lot! (As long as you be careful not going to bananas with it).
The biggest obstacle I had to overcome in this project would be to make the AI pursuit the player in a good way. I did not want to make my level designers have to place out jump points, so I created some logics for the AI to get details about the environment around them.
This was the main update function for all the enemies. Looking back at it now, I wish I would have rearranged some of my code so that the check IsImmobile() is at the top of the update function returning false if the enemy is immobile. Also fixing some if-statements that are difficult to read. In order to make sure that the enemy would not punch away boxes, breaking the game, I added a check when punching making sure I would only spawn hitboxes if they are punching the air or the player.
The myAISensor was a class that handled that checks for terrain. To determine if there was a hole beside the enemy, the enemy had hitboxes below the feet. One to check if there was a hole, another to check if there was a platform further ahead that was possible to jump to. When these collisions happened, the sensor would raycast to get more details about how far of a jump is it, or if there was a platform beneath, safe to fall down to.
Here is the code how the enemies handled jumping. HandleHole() is as it sounds, when there was a hole in front of the enemy. The designers wanted the enemies to jump if there was nothing ahead of them, a way for the player to breath out having escaped the threat.
HandleTerrain() was if there was a small box or little ledge in front of them. The enemy would jump on that object if that was the case.
The code for jumping is done by a distance required to jump with an angle to jump with. The jump force is calculated with a projectile calculation. I believe I found something from UnityForum and used it.