Setting up sound types and assignments.
In this tutorial we’ll use Sound Types and Sound Assignment components to play different audio clips when the ball hits game objects. You can learn more about this in the audio and music documentation.
First, we’ll set up the sound type that we’ll use. Open the Makinom editor and navigate to Base/Control > Sound Types.
There’s already a Default sound type added, we’ll just rename it.
Navigate to Templates > Sound Templates and select the Default template. Change the following settings.
Click on Add Sound.
Add a new sound template and change the following settings.
That’s it – click on Save Settings to save the changes.
Now, we’ll create a schematic that’ll be attached to the Ball that plays the sound type when colliding with other game objects.
Navigate to Schematics, create a new schematic and change the following settings.
Add > Audio > Audio > Play Sound
We’ll use this node to play the Hit sound type on the game object that was hit (i.e. the starting object).
Depending on the audio clip that’s assigned to the sound type on the game object (using a Sound Assignment component), a different sound will be played.
That’s it for the schematic – click on Save Schematic and save it as HitSound in Assets/Schematics/.
Next, we’ll add the HitSound schematic to the Ball game object (child object of the Paddle game object) in the scene using a Collision Machine.
Select the Ball game object and add a collision machine component (e.g. using the component menu: Makinom > Machines > Collision Machine). Change the following settings.
Don’t forget to apply the changes to the prefab by pressing on Overrides > Apply All (top of the inspector when the Paddle game object is selected).
We’ll now assign audio clips to the Hit sound type on different game objects using Sound Assignment components.
We’ll assign the Hit Wall sound template to the Paddle game object, the 2 Wall game objects (child objects of the Level game object) and the Roof game object (also child object of the Level game object).
Add a sound assignment component to the game objects (e.g. using the component menu: Makinom > Scenes > Sound Assignment) and change the following settings.
Don’t forget to apply the changes to the Paddle game object to update the prefab.
Finally, we’ll assign the Hit Brick sound template to the 3 brick prefabs (Brick 1, Brick 2 and Brick 3 – the prefabs can be found at Assets/Tutorial Resources/Prefabs/).
Add a sound assignment component to the prefabss (e.g. using the component menu: Makinom > Scenes > Sound Assignment) and change the following settings.
And that’s it – don’t forget to save the scene.
Hit Play to test the game. Now, the ball will play sounds when colliding with the paddle, walls, roof and the bricks (which you’ll only hear for bricks that aren’t destroyed by the hit).
This concludes the breakout game tutorial series. You can add additional content to the game, e.g. new levels, harder bricks (increasing the health) or random brick placement (using a schematic that spawns bricks by chance).
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!