Learn more about sound types and sound assignments, and how you can use them to improve your workflow.
You want to play a different sound depending on which game object was hit by a bullet? Sound types are an easy way to do this without having to change schematics or override audio resources.
Sound types are an easy way to play different audio clips on different game objects without changing schematics or audio resources. In short, you can assign an audio clip to a sound type – by playing a sound type on a game object (e.g. in a Play Audio node), you can just play whatever audio clip is assigned to the sound type on a game object.
You can assign audio clips to sound types in Sound Templates and Sound Assignment components.
Sound types are set up in the Makinom editor in Base/Control > Sound Types.
A sound template is a reusable assignment of audio clips to sound types. The templates can be used in Sound Assignment components to add the audio clips to a game object.
If you need to change the audio clip assigned to a sound type (or add additional assignments), you only need to change the sound template instead of having to change it on all prefabs or game objects that use it.
Sound templates are set up in the Makinom editor in Templates > Sound Templates.
Sound Assignment Components
A sound assignment component adds the audio clips assigned to sound types to a game object. You can use a Sound Template as a basis for audio clip assignments to sound types and add additional assignments to the component directly.
When playing a sound type (e.g. in a Play Audio node), the sound assignment component is used to find the audio clip that is assigned to the sound type.
A Raycast node is used to hit game objects with a gun. The found game objects (added to a local Selected Data in the schematic) are used in a Play Sound node to play a sound type on them.
The game objects use Sound Assignment components to assign different audio clips to sound types:
- Hitting a water game object plays a splash sound.
- Hitting a metal pipe game object plays a metallic hit sound.
- Hitting a wooden crate game object plays a wooden crack sound.
Depending on an equipped weapon, a different prefab is attached to the player. When attacking enemies, a Play Sound node is used to play a sound type on the equipped weapon prefab.
The prefabs use Sound Assignment components to assign different audio clips to sound types:
- A baseball bat prefab plays a dull wooden hit sound.
- A metal pipe prefab plays a metallic hit sound.
- A sharp sword prefab plays a slashing sound.