Implementation Walkthrough || Adding Sounds to Mix and Jam's Unity Project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] there's a channel on YouTube called mix and jam and this is a fantastic resource for game developers where they deconstruct logic and behaviors from different games I also added a few partical effects to make the level look a little bit more organic and after a bit of adjustments this is how it turned out but there's no audio so this creates a great opportunity to add sound and code for these projects in this video I'm taking one of their projects and demonstrating how we can add an audio implementation using fot so first let's see how the result can [Music] work [Music] for each video they have a GitHub resource with a Unity project so we'll download the zip and open it up in the unity [Music] [Music] hub first we need to figure out what needs s sound and how to trigger this from the existing code playing through the level I made some notes of objects and actions that could use audio such as the tower turning and pivoting footsteps is always a good place to start but before we do this let's have a look at where we can find the code that triggers the other functions on the player object there's a player controller script and this has the mouse action so if we wanted to add sound to these then we could add this [Music] here if the player has other controls then this could be a likely place for these or we might be able to use the animations like we will for the Footsteps in this case the the game manager has some of the other methods we need we can just search for the input methods to find likely places to start and if the project is used in the new input system you can look for the names of the controls in the player input component in this case the game is using the arrows to rotate the tower so we can add a debug message in this method to check if this is a good place to put our audio trigger for the part of the tower that pivots I had to search around a bit but I found that the cube with the red mark had the is button ball checked looking in the player controls we can see that this calls the rotate right pivot method in the game manager adding a few debug messages we can see that we can add sound triggers in both player controls and the game manager and in our case the difference is simply the timing of the action now that we have some information on where we can put audio code let's let's start with the footsteps we'll use the animations and animation events and for this I created a script called play footsteps and place that on the player object that has the animator that way we don't need to add a separate reference for this later on I then created another script called footstep manager and added this as a serialized reference so we can add this in the inspector the play footstep has a public method called footstep down with an INT as an argument we can use this int to change an FM parameter to set the footsteps material so I've called that kind in the footstep manager there's a corresponding method called play footstep that takes an INT as an argument and I'm calling that layer then I added animation events to the animation and use the public method from play footstep with an in for each new animation type that is walk stairs up and stairs [Music] down [Music] in F mode we have an event called footstep with a labeled parameter called terrain each label will correspond to the ins in our footstep method and will add our sounds to this parameter track we'll copy the path from the F mode event and use that in our calling method if you not used fod functions before you can check out the video game audio coding using F mode and the link is in the description first we'll check that our footsteps are playing as they expected then we'll add the parameter function with the corresponding int so now when the player character is using the different animations the script will take the ins that we added in the animation events it's worth noting that although this is a valid method I had to tweak the blend controls a bit in this case to make the switch work correctly keeping the animation event code separate from the script calling fod allows for more flexibility for instance if we wanted to switch audio syst system we would only need to change the code in the F mode manager for the other functions such as the tower moving and pivoting I've used a similar method and created a script called fod sound manager however as I wasn't entirely sure if more than one script would be using this I created this script as a so-called Singleton this means I can call its enclosed methods without having to add in script in the inspector or get it at runtime there's not enough scope in this video to cover how the script type works and all the pros and cons but I've added a link in the description to an article on the subject in this sound manager I'm calling all the one-hot sounds that we need such as the to turn I've also added some additional functions to the original code and add in an on completion for the tower tney but this isn't necessary and the sound could just be timed in the F mod session instead I also added a trigger to the final cube with a script that cause an end Stinger this trigger also stops the music and water ambiances that are set from the F Ambience script as these are likely to be different from level to level I wanted them in a separate script from The Sound Manager [Music] [Music] [Music] [Music] links in the description to the fod scripts that I've created for this project although I would encourage just starting from scratch and using this video as a guide instead hopefully this was helpful and happy game audio
Info
Channel: Night On Mars
Views: 203
Rating: undefined out of 5
Keywords:
Id: gbHwUK3icA8
Channel Id: undefined
Length: 10min 20sec (620 seconds)
Published: Thu Dec 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.