Time for action - add sound to a weapon

The weapon system of CryENGINE 3 supports various actions, which are used to trigger actions such as animation, effects, and sounds. Within the weapon system, one-shot, tail, and looping sounds are the typical types of FMOD events used.

  1. Open one of the weapon scripts within your game directory. Weapon scripts are stored under GameScriptsEntitiesItemsXMLWeapons.

    For this example, we will open the SCAR.xml file in a text editor.

  2. When looking through this file, you will see that there are many actions triggered by game code that have a sound event attached.
    <action name="fire">
        <animation target="firstperson" name="fire_bullets_right_%suffix%01" />
        <animation target="owner" name="shoot" />
        <sound target="firstperson" name="sounds/weapons:scar:fire_single_fp" radius="200" static="1" />
        <sound target="thirdperson" name="sounds/weapons:scar:fire_single_3p" radius="200" static="1" />
    </action>
    <action name="rapid_fire">
        <sound target="firstperson" name="Sounds/weapons:scar:fire_loop_fp" radius="200" static="1" synched="1"/>
        <sound target="thirdperson" name="Sounds/weapons:scar:fire_loop_3p" radius="200" static="1" synched="1"/>
    </action>
    <action name="spin_down">
        <sound target="firstperson" name="sounds/weapons:scar:fire_tail_fp" radius="200" static="1" />
        <sound target="thirdperson" name="sounds/weapons:scar:fire_tail_3p" radius="200" static="1" />
    </action>
  3. First, let's discuss some of the properties here:
    • The action name= property specifies weapon action in conjunction with game code.
    • The sound target= property specifies first person or third person sound in conjunction with game code.
    • The name= property specifies the sound event name starting from the sounds root folder.
    • The radius= property specifies the radius of the sound to which the AI entity reacts.
    • The static= property specifies whether sound should stop immediately when switching the weapon.
    • The synched= property specifies whether the sound should look for sync points within FMOD and plays until the next marker before stopping.
  4. To use sync points, the asset and FMOD sound banks need to be set accordingly. The asset itself requires that sync points be defined by markers, as seen in the following screenshot:
    Time for action - add sound to a weapon
  5. The sound bank must set the property Enable Sync Points to YES.
  6. For multiple tail setup, the FMOD event requires the environment parameter.

    This directly connects with the Reverb Presets environment's setting. It enables different tail settings, depending on the environmental setup.

    The following screenshot shows an example of such a setup:

    Time for action - add sound to a weapon

    In each case, the upper layer with just the attack of the single shot is being triggered. The second layer reacts to the environment setting triggering either a long outdoor tail (0 - 1.5) or a shot indoor tail (1.5 - 3).

    This system can easily be enhanced by increasing the environment parameter values and adding more sound definitions. To trigger the required tail behavior in the game, the ReverbVolume entity requires the environment entry to be set correctly.

What just happened?

You have now learned about using sounds and weapons together so that you can create your own weapon sounds. You have also seen how you can make them interact with the ReverbVolume entity to make the sound blend into the level more seamlessly, as discussed earlier in the chapter. We also saw where to add sound events so that they are played on certain weapons. Additionally, we discussed the relevant properties used by the sound and weapon system to trigger sound events.

Weapon sound workflow tips

Creating one FMOD project per weapon has proven to be a good choice. It not only helps to keep an eye on the memory budget but also enables multiple designers to work with multiple weapons at the same time. Splitting the FMOD sound banks according to the sound target as well as a "shared" bank for elements, which both targets will use, will decrease the memory usage. It also enables the Audio File Cache Manager (AFCM) to only load the sound bank, which is needed via the gamehint system. Also, reusing the tails on single gunshot sound events does save some memory, since the actual attack of the gun is fairly short and thus requires less memory.

Also, using FMOD's granular functionality helps to save memory while avoiding repetition.By doing this, the original loop gets cut into small pieces of three to six shots and randomized via the Sound Defs property, as shown in the following screenshot:

Weapon sound workflow tips

Pop quiz - creating sound for your game

  1. What is the tool used, in conjunction with the CryENGINE game engine, for creating and compressing sound assets for ingame use?
    1. Soundguru
    2. Adobe Photoshop
    3. Fmod Designer
    4. Visual Studio
  2. When using the various sound entities, to what are they targeted within a level to play them?
    1. Area Shapes
    2. Irradiance Volumes
    3. Time of Day
    4. Tag Points
  3. What entity is best used, when creating a random sound asset using multiple sounds within a single sound definition?
    1. BasicEntity
    2. RandomSoundVolume
    3. AmbientVolume
    4. ReverbPreset
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.235.8