UE5 FPS Demo
This project is a demonstration of intergrating Wwise into the Unreal Engine 5 First Person Shooter Demo game.
Sections include creating an ammo counter, creating the Wwise project, assigning ammo to a game parameter to change RTPC values, and stop the gun from firing when the ammo counter reaches zero.
The first thing to do is create an ammo counter and have it visible to the player. As the counter gets close to reaching zero a mechanical layer gets louder. When the counter reaches zero only the mechanical layer plays. First a visual representation is needed so that the current ammo count can be easily identified and checked that the audio events and game syncs are called at the right times.
Using a Widget and attaching it to BP_Rifle a a visual of the current ammo count can be displayed using the variable AmmoCurrent. In the BP_Rifle blueprint the variable can count down and change the value of AmmoCurrent.
This video goes in-depth on how to implement the Ammo widget.
In the Wwise project the gun audio is split up into 3 sections; fire, mech, and tail. The variations for these audio files are places in random containers. The Fire and Tail containers are placed in a Fire event while the Mech layer is in its own.
In Game Parameters a parameter called AmmoCurrent needs to be created and controlled by AmmoCurrent variable in the UE5 project. In Wwise the AmmoCurrent Game Parameter is attached to the Mech random container RTPC controlling the voice volume.
The Widget displaying the ammo count has a max value of 40, minimum of 0, and default set of 20. The Game Parameter AmmoCurrent will reflect the same values and controls the RTPC voice volume of the Mech random container.
When initially opening the BP_Rifle Blue Print the OnFire Projectile event is connected directly to the SpawnActor BP First Person Projectile. This section is where all Wwise related events will need to be placed.
The first component placed is the AmmoCurrent RTPC so that the value of the AmmoCurrent variable can be relayed to the AmmoCurrent Game Parameter.
The AmmoCurrent variable is also connected to the input of an Compare Int component which is check after the RTPC value is changed. The Compare With value on the Compare Int component is set to 0.
Any number that equals 0 or under triggers only the Mech Post Event not triggering the component spawning the projectile or the Fire post event. Any number greater than 0 will trigger the projectile component, then the Fire Post Event, then the Mech Post event.
Setting everything up this way will always ensure the Mech Layer will play regardless of how much ammo the player has. The Fire, Tail layers and the Projectile spawns to any value above 0.