P7 - Sub Umbra

Reference game: Alan wake II

Engine: Custom engine developed by our group

My contributions:

  • Shooting and weapon systems

  • Player actions

  • Flashlight mechanics

  • Entity stats and base character architecture

  • Animation state linking

Time: 15 weeks, 20 h/week

Shooting and Weapon Systems

I developed the shooting and weapon systems of P7 as part of my specialization project. For more detailed information, see the Specialization page. Note that P7 only features the revolver and shotgun.

Player Actions

Adding Actions

When a character is initialized it adds its actions to the StateHandler. This way the StateHandler can store actions without having to create a new object each time an action is triggered.

Starting and Stopping Actions

Each action is started and stopped through its character, making the character an interface for its own actions.

Example of an Action

As an example of an action's life cycle, when the player scrolls the mouse wheel the player controller calls on Player::StartSwitchWeapon. When SwitchWeaponAction begins it resets a timer and plays a sound. After it has ticked past its timer it tells the player to stop the action.

Because actions are responsible for their own behavior and independent from any other action, they are highly modular and can be easily expanded upon.

StateHandler

As part of my work with the player and enemies in P7 I created an action system that uses what I dubbed a StateHandler to manage each character's actions. Each character owns a StateHandler, which in turn manages all the character's actions.

The Flashlight

The flashlight is an important part of the game's combat. Like in Alan Wake, enemies take reduced damage unless the player shines their flashlight on them for long enough. The flashlight gives a wide cone of light in its normal mode, but it can also be focused into a more intensive ray by spending flashlight battery. The player can only weaken enemies with the flashlight when it is focused.

Split Raycasting

I use raycasting to detect if the player is shining its flashlight on an enemy. In order to save performance the racyasting is divided into two segments. Every other frame I draw 7 rays along the outer edge of the flashlight and one in the middle. The next frame I draw only 4 rays that are closer to the middle of the cone, as well as one right in the middle. Any enemy that is intersected by a ray is saved onto a vector that is only cleared when that same set of rays is checked again.

Pointing the Flashlight towards the Crosshair

Much like with the shooting in my specialization, I made the flashlight point toward the center of the screen. First I raycast from the camera straight forward. If the camera ray would intersect with an object, a second raycast from the flashlight joint on the player mesh would be drawn to the collision point. Otherwise the flashlighlight directs itself towards a point far in front of the player.

Entity Stats and Base Character Architecture

Similar to P6 I implemented not only the stats of the player, but also all the base variables and functions shared between all entities and characters.

I implemented much of the shared code between the classes at the start of the project using P6 as a basis, rapidly setting up the initial structure that could be applied from the code used in that project, but I also iterated upon it during the rest of the game's development.

Animation State Linking

Again like in P6 we implemented animations into the game using a animation state system. Each animation state has its own exit conditions, meaning that they can have their own tailored transitions to other animatons.

For P7 I implemented all animations and exit conditions for the player as well as some other minor gameplay features.