First person shooter
In our seventh game project at The Game Assembly we were told to make a first person game. Our reference game was a game called "High hell". Our engine is a script focused engine so this game was made entirely with scripts.
1. Refactorized our event callback system
I remade parts of the event callback system because the old way was a hassle for our animators to add triggers to specific frames to our animations. You can read more about our old way of handling it on the tab "Spite" in TGA Games. The new way allowed the animators to add which frame to trigger and the name of the event in a json file with the same name as the animations. When we load the animations into the game we also check if there is a json file with the same name. We add the events from the file and we also add them to our scripts index picker.
I scripted the part of the health bar which made it shrink when taking damage. I also scripted a damage vignette when taking damage which fades out.
3. 3D Sound and volume settings
I added functionality for 3D sounds and made the audio script nodes have ID as a output. The sound in the game is components so the ID allowed us to stop specific sound and change a sounds transform.
Every game on TGA has high volume and no volume settings so I decided that it would be convenient to add that. I made it so that our engine loads 2 audio banks, MusicBank and SFXBank. I added a string for a sounds bank name in their structs so I could lower the volume of a bank and loop through the sounds playing and turn down the volume of the sounds with a matching bank. I also multiplied every banks current volume with a mastervolume.
The image above is the function I used when decreasing the volume. It's not a good way to do it but I prefer quick solutions and this didn't take much time. I also made a Get and Set node for all 3 banks so our level designers could make volume settings using script.
The video above contains the volume setting. Listen with sound on if you want to hear how it sounds.
4. Made parts of the AI
I made it so that the enemy rotate their heads and look at the player when they detect the player. I also made their attack state which makes them shoot projectiles. I made them able to take damage and I made them able to die.
5. Place camera on a joint in the mesh
I worked together with another programmer to place the camera on a joint made by our animators. It was a bit tricky to get the hierarchy correct. At first i wanted to make the camera a child to the player mesh and have the mesh be a child to the playercontroller. In the end they were both children to the player controller and the camera set its position every frame on the camera joint.
Above is a image of some of the code for our first person camera node. We center the mouth in the middle of the screen and get its delta rotation when it moves. We use this to rotate the playercontroller around the Y axis and we rotate the camera around X and Y axis.