FMOD & Unity | Adding Game Sounds | Part 1 - OneShots & Animation
Вставка
- Опубліковано 28 сер 2024
- Welcome to a brand new series!!! Here I'll be extracting sounds from Unity's 2D Game Kit and implementing them back using FMOD and C#. Today we're starting with the main character and adding her 'melee attack' and 'damage taken' sounds. We'll also be adding sounds to animation which is a first time for us!
Need the scripts from this video?: scottgamesound...
SURVEY!!! 'FMOD & Unity | Better Videos Survey': goo.gl/forms/r...
Unity & FMOD | Creating An Audio Settings Menu: • FMOD & Unity | Creatin...
Unity & FMOD | Stopping All Events & Destroying Instances:
• FMOD & Unity | Stoppin...
Please let me know if you enjoyed. :D
Need audio or music for your game? Feel free to email me at henry@scottgamesounds.com. Or follow me on twitter @henryscott0.
My Music: / henry-scott-129106045
My Site: www.scottgamesounds.com
Blog on mistakes I make as a freelance Sound Designer: www.scottgameso...
So glad you made this series. This is a massively helpful contribution to the game audio community.
Two comments from Akash in one day??? Omg I must have done something right haha. I wouldn't be doing any of these videos had I not found your channel so thanks a bunch for all of that inspiration.
Thanks a lot for making this - for me this was much better than the official FMOD tutorials! Hoping to see more :)
No problem, glad you found it helpful. You definitely will be, I'm working on episode 5 now!
Just wanted to let you know your videos are awesome Scott
Aw thanks a bunch Hernan. Seriously that really helps keep me going, knowing they're appreciated that much! Just had a quick look at your channel. Keep up those rocking tunes my dude!
@@ScottGameSounds You're really helping man, it's really appreciated. And btw thanks for passing by and for your words.
Great video scott! That animation script is a lifesaver! :)
Cheers Fred, glad you've found it helpful
I really love it, that you laugh that much. It makes this tutorial that much worthier than it is anyway due to the facts you are transporting here. Thank you very much for explaining and entertaining. :D
What can I say? If you're not laughing your crying I guess hahaha. Thanks so much for your comment Julius. Honestly you're the first person to comment on the way I'm delivering these videos in this relaxed and playful manor. That means a lot to me that you picked up on it AND actually enjoy it. Thanks a ton!
So helpfull! I was having a hard time searching for FMOD tutorials. Thank you so much! :)
Glad it helped! Thanks for watching Carol!
Thanks a lot for your work this is like the only resource for this.
Excellent! Looking forward to try this for Space Chef instead of coding it myself in Unity :)
Good luck with Space Chef BlueGoo. Glad I could help :)
This is a big help. The scripting thing is confusing though. How do we, as music makers, learn to code like this?
Hi! I have a question. I do every thing like you, but i have error message, that PlaySound has no reciver. Whats the problem, can you help me? Fmod studio listener in main camera
Hi. It sounds like that something is missing. I would just double check that you've added the name of the function 'PlaySound' is written inside the animation event's 'Function' field. Then also make sure the function you've written is called 'PlaySound' exactly.
This error is basically telling you that Unity can't find the function that you're trying to trigger, so just make sure it cane by double checking spelling and stuff. I sometimes find that when I create an animation event and fill in the 'Function' field and then move on to something else, the field is still empty when I return.
Oh and don't forget to save the changes you've made to the animation event. There should be a 'save' or 'apply' button, or something similar, at the bottom of the inspector tab so make sure to click on that too.
Best of luck, let me know how you get on.
@@ScottGameSounds I solved the problem. Fmode player function should not be added to the prefab itself, but where the animator is located. I apply your lessons for another game, I do it by analogy. So sometimes I face difficulties
@@IamDenis.s Oh well done! I was completely wrong hahaha best of luck with your game!
@@IamDenis.s Hi can you please clarify this for me? I'm having the same issue
@@moresounds4862 just add function in prefab, where the animator is located
There is an error [FMOD] Event not found, and sound is not played. What should I do?
Hi Scott, I like your tutorial but I got a problem. Animation Event only has a function and no string or other stuff down there. And Playsound can't be found in function. What should I do?
Great (tutorial) Scott!
HAHAHAHAHA That has got to be my favourite comment I've ever recieved. Thanks Nishanth!
@@ScottGameSounds Haha! That's the first thing that came to mind when I finally got the sounds playing through the game. Thanks for sharing this series!
Hi Scott, thanks for the great tutorial. One question: I noticed you didn't make the PlaySound function in the FmodPlayer script public, and yet the Animation Event was able to access that function--which is unlike a UI button, for example, where you must make a function public (and drag in the appropriate script to link the script to the button event in the inspector) in order to be able to access that function in the functions dropdown. I guess it's not necessary for animation events--very interesting!!
Yeah you'd think it would need to be public but nope! I wonder if it would still work if we made it private??? That might be pushing it, but who knows!
I downloaded the 2D Game Kit project and then when I import the FMOD package it's not showing up in the menu. I tried importing it again and it says it's already in the project! I had the same problem with the Viking Village project and couldn't get it working. I'm using the latest version of Unity and FMOD. Any suggestions?
Hey Jonathan. Do you mean that you cannot see the "FMOD" menu option at the top of your project? I think that's a bug. I've had people ask me about this problem in the past, but to be honest, I still haven't been able to figure out what causes it and what can fix it. The only thing I can suggest is for you to try again with a new Unity project. I know that might be a bit of a pain, but it's all I can suggest to you right now. Sorry I can't be much more help. Let me know how you get on.
@@ScottGameSounds yeah there wasn't an FMOD menu. I was able to fix this by importing the FMOD package into an empty project first, and then importing the 2D Gamekit project. Weird, but Unity is full of little surprises like that.
@@jyandel1 Oh great, glad to hear that you got it sorted. Let me know if there's anything else I can help you with.
Hey all! maybe someone can help, I'm following this tutorial but I'm stuck at the Ellen_Melee part, when I use the weapon in the game I get: [FMOD] Event not found: event/SFX/Ellen/Ellen_Melee
This has probably to do with the Fmod Player Script (at 27:39), because in the tutorial it is not shown where it's supposed to be located, so where is it supposed to be located? mine is currently located in the Assets folder, so could that be the reason for the error?
those are further details of the error:
[FMOD] Event not found: event/SFX/Ellen/Ellen_Melee
UnityEngine.Debug:LogWarning (object)
FMODUnity.RuntimeManager:PlayOneShot (string,UnityEngine.Vector3) (at Assets/Plugins/FMOD/src/Runtime/RuntimeManager.cs:1087)
FmodPlayer:PlaySound (string) (at Assets/Plugins/FMOD/src/Runtime/FmodPlayer.cs:16)
ok update: it was a typo, i forgot the colon in event:/SFX/Ellen/Ellen_Melee ^^
sorry it took me so long to get around to your comment LB, but glad to see that you've sorted it out! Keep it up!
Awesome video so far! I'm confused as to how you got the audio from the assets folder in Unity to appear in the Fmod project's audio bin. Maybe I'm overlooking something simple.
Thanks a lot! That was something I manually had to do. I had to go into my compuetrs folders, find the unity project, go through to Assets - > Audio and find all of the .ogg audio files that come with the 2D Game Kit, then copy and paste it all into my FMOD projects Asset folder.
Thanks! I realized thats the only way after I posted this question. Great videos! Learning a lot
Hey Scott :) is there a Guideline how to Add Sounds to the MainMenu? I sadly couldn't find a Video. All the Best, Shane
No sorry I haven't yet made one. But thanks for letting me know that you'd like ot see one. I'll add that to my list of video ideas.
@@ScottGameSounds hey thx for the reply. ye I wanted to add some sounds to the 2D Game Kit Menu :D would be nice to see something soon. Take care & keep it up
Hello! I'm trying to learn something about implementing sound in games, do I have to learn engines like Unreal or Unity first?
Hey Francisco. I wouldn't say that you need to know everything about Unreal or Unity, but to get familiar with the basics of one of those would definitely help. Give them both a try and see which one you find more appealing to you. There's plenty of great tutorials on YT for both engines. I hope that helps?
@@ScottGameSounds
thank you very much for your response and videos. Really helps!
I've been trying to mess around with some of these things as I've been going along the videos, one of the issues I've ran into though is something about the RuntimeManager, the error code reads CS0102 'The type 'RuntimeManager' already contains a definition for 'PlayOneShot'. Except I haven't touched that script and it's when I've gone to edit other scripts in a Unity project it breaks and if I undo everything I've done and save it, it's still broken, any ideas?
Whats in these other scripts specifically? All that error is saying is that the RuntimeManager scirpt already has a definition in it called PlayOneShot. The keyword is 'already' suggesting that Unity thinks you're trying to create a new PlayOneShot function. It's possible that the PlayOneShot function isn't being called corretly. Can you copy and paste the script you're using that causes that error to appear and I can take a look at it for you
I can see how this can be helpful to some, but I get completely lost when you go into the game code and all
Hey Scott, is your page working fine? I mean, i can't go further beyond "Sign me up" and "Find out more" buttons :( I was looking for the script. Thank and great videos!
Yeah sorry Cristian but my website is being re-built in order to support an online course I'm building that teaches FMOD implementation with Unity. The scripts aren't available currently because of it. I'm really sorry for the inconvenience and will try and put them up as soon as possible. Glad you enjoyed the video!
@@ScottGameSounds Ugh, bad timing!
@@CJPEREZD Which script did you want? I could copy and paste it here for you? or email it to you if that's easier?
@@ScottGameSounds I'd like to develop a FMOD events manager, persistent between scenes, in order to be able to shoot different events such as "BackgroundSounds" or one-shot like "UIsounds", etc. My plan is to have a gameObject with that script attached, giving me the chance to add it as a component of another one, or simply refer it from another script. I'm thinking out loud here, but i'm trying to design the cleanest way to handle, storing all the sound and music behavior in one object, if that is possible at least.
Scripts are back! scottgamesounds.com/c-scripts/
If I'm completely honest, I've never made a script to act as an event manager for FMOD, as FMOD kind of acts like the manager anyway. I'm sure It's total possible. Just create your event instance in one script, attach it to an empty gameObject and use other scripts to trigger them like you said. I've always just attached event instances directly to the gameObject I want the sound to play from.
A total newbie here. I basically did everything step by step, and got a prompt for Event not found for the Ellen hurt sound. How do I designate to use the correct event from fmod? The project is connected and all of the structures and scripts should be identical to what you did.
In FMOD your events may appear "unassigned", in this case you need to right click on your events and choose 'Assign to Bank' and then choose Master. Then save and rebuild the Bank. It should work now, he skipped it in this video.
@@cuteevilMv you just made my day with this comment, thanks so much kind stranger!
Thank you
No problem :)
Hello! I'm getting this error while trying the game with the new command.
"ArgumentException: The specified path is not a legal form (empty)"
Thanks!
Hey Alejandro. Thanks for your comment. You could describe the issue you're having a bit more, it's been a while since I posted this video. At which point in the video do you get the error when following along? The fact that the error mentions a "specified path" makes me initially think that the event path you've entered is either incorrect or is not being passed into the event correctly. Instead of trying to pass the event path from the animation we wrote into the function, maybe trying feeding the event path directly into it. So for example you might put 'FMODUnity.RuntimeManager.PlayOneShot("event:/FolderName/EventName");'. I hope that helps, let me know how you get on or if that didn't quite make sense.
@@ScottGameSounds Thanks for answering so fast! I'm really trying to get into this game composition and sound design world. So even though I tried a couple of things, it seems like I didn't quite get what you said there hehe. When I star the game there's a red error that says:
"ArgumentException: The specified path is not of a legal form (empty).
System.IO.Path.InsecureGetFullPath (System.String path) (at :0)"
And I soon as I die with Ellen, there's this yellow one:
"[FMOD] Event not found: event:/SFX/Ellen/Ellen_Hurt
UnityEngine.Debug:LogWarning(Object)"
@@AlejoVCuevas No problem Alejandro, happy to help! That second error is a pretty simple one. It's basically saying "hey, I know you told me to play the event:/SFX/Ellen/Ellen_Hurt event, but when I went to play it, I couldn't find it." So to fix this, just make a few checks.
First check that all of your folders your event is nested inside of in FMOD as well as the name of the event itself, are all correctly spelt and match exactly "SFX/Ellen/Ellen_Hurt".
Next make sure you've assigned the event to the master bank. Right click on the event in FMOD, choose assign bank -> master bank, then press F7 on your keyboard or go click on File -> Build.
Once you've done both of these things, I'd recommend that you go into Unity and choose the FMOD tab at top and the Event Browser. From here you can find your event. Click on the event and there should be a little 'copy' button that looks like tow pieces of paper. This will copy the event path for your perfectly. Then just replace your old event path with this copied one.
If you're adding the event to the animation, paste it in the 'string' box. If you're adding it directly to the PlayOneShot function, paste it in the ( ) signs, but make sure you also put quotation marks around it. It should then look something like this:
FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/Ellen/Ellen_Hurt");
As for that first error, that is a Unity error. I'm going to have to look that up for you and see what I can find.
@@ScottGameSounds Still can't make it work, but I could follow every step on your tutorial which is great. I'm going to try re installing FMOD and not touching any of the saving location settings because I've already used up all my resources and that's the only thing I know how to do properly hahahaha.
Thank you for your time! And I might be bothering you again in some other videos.
@@AlejoVCuevas Feel free to bother me haha. Yeah try re-installing, ya never know, that might fix it. Let me know how you get on.
Sorry if I'm missing something obvious but is there a way to download this game for Unity in 2020 so we can do the tutorial ourselves? I couldn't find it. Thank you!
Yeah. If you go onto the Unity Asset store and just type in 2D Game Kit, you should find it, even with the latest version of Unity. Really happy to hear that you'd like to follow along thanks a lot Max!
@@ScottGameSounds Found it, thanks so much!
Hi Scott, Thank you for your great videos! I have been running into some troubles lately with FMOD. I am currently developing a VR application, and for the music i use FMOD as medium and the Oculus Spatializer for spatial audio. However, when i have run my application for a few times, suddenly I get the following error "[FMOD] PluginEffectModel::init : missing DSP plugin 'Oculus Spatializer' "; The strange thing is that both my FMOD project and my Unity have the plug in attached/imported. Have you maybe run into this problem and perhaps have a solution? :)
I can't say that I have unfortunatly. I've only used the Oculus spatialiser with Unity and FMOD once or twice. I certainly haven't built anything with it. Sorry I can't be of any more help A MD, but thanks a bunch for writing such a loevly comment. I really appriciate your support!
@@ScottGameSounds No problem! Thanks for your reply :)
Im getting the error "Assembly has reference to non-existent assembly 'Unity.ugui' "
Hey Tom.Can you tell me more about the error? Like when does it appear, what were you trying to do, what is it preventing you from doing etc. I've never had an error like that before
have try playing with codemasters grid or dirt game i been trying edit fev or bdl files no luck i know they use fmod for sounds could look into it find way i mod sounds thanks.
Thanks, Scott. I'd love to stick to your workflow, but unfortunately for some reason during the "2d game kit" import Unity crashes while doing the last reload. It actually asks me for two reloads , due to some updates in scripting or something. So at the last Unity reload it crashes every time and I'm left with an empty project. Help materials where not really "helpful". What could be a way out?
Off of the top of my head, I'm not too sure. Could you tell me what version of Unity you're using? I could do some research to find out why then. I might try making a new empty project and importing it again myself to see if I get the same issue.
@@ScottGameSounds , thanks a lot for getting back. Well, now it's hard to tell, but I eliminated this problem with the "weapon of persistence" - I just repeated the operation a dozen times and at some point it didn't crash. It's like hitting a old TV-set - not knowing what's going on under the hood, you somehow get it to work )) Anyway, answering your question: my Unity version is 2018.3.8f1
And thanks again for replying !
Hey sometimes the simplest methods are the best haha. Let me know if you have any more questions Viktar.
Thanks again, Scott. You're producing a really valuable and usable content - without skips and jumps like in many other tutorials that don't start from scratch and say things like "well, you know how to do that" - and then you suddenly realize that this method simply doesn't work they way they say , because they simply forgot to mention something. So, yeah, keep it up, and good luck with more subscribers, views, fame etc etc. ))
@@VictorBardaque Hey thanks so much Viktar, those were some really kind words, I think that's made my day. And I'm glad to hear my tutorial style works for you, I always get concerned I'm making these videos too long, so to know every detail is appropriated clears that worry of mine right up! Best of luck to yourself too in all your endeavours!
Hey Scott! Have you got an idea how to write a script for unity that one could add to an object which you can pick up with a first person character and triggers a FMOD event upon collision with the ground or other objects once you drop that very item? No matter if it's a can or a book or any other pickupables in a game. I'm asking because I'm an audio design student with no scripting knowledge and need it for a student project but just can't seem to find any scripts for this purpose. Additionally, all programmers I know haven't scripted for FMOD and Unity before, just Wwise. It would be absolutely awesome if you could help me out with this one. Thanks in advance!
Hey there Käswurst. Yes that's definitely possible to do, even at a basic level. I'll try my best to explain it for you.
So in C# scripting, you can use different functions, that will do something for you (for example play an FMOD event) depending on what function it is and how it works. Two very basic functions are the Start & Update function. The start function will do something for you on the every first frame that the script you're writing in is activated in your game. The update function does whatever you tell it to, on every single frame. So for collision, you'll want to collision function that looks like this:
void OnCollisionEnter (Collision col)
{
}
The word void, don't worry about. You need it, but it's not important to know how it works.
OnCollisionEnter, will do something that you tell it do on the initial frame that an object collides with another.
The two words in the ( ) symbols make up a variable, with he word 'Collision' being the type and the word 'col' (which you can change if you want) being the name. You can use this inside the function to find information about what it is you're object has collided with. For example you might want to check the name of the surface first in order to change the collision sound depending on the material of the floor your item has hit.
Inside the { } symbols is where we'll tell our function what to do when our object collides with the floor. If you have an FMOD event ready to go, I'd suggest using this:
FMODUnity.RuntimeManager.PlayOneShotAttached("event:/EVENTNAME", gameObject);
This will play an event at a location that you give it and then stop the event once it's finished. All you have to do is replace the part where I've put EVENTNAME with the name of your event, exactly as you've written it in FMOD.
The part following this that says "gameObject" is where you tell it where to play the event. For simplicity, I've written 'gameObject' so that the sound is played wherever the falling object lands.
So put those together, and you get this:
void OnCollisionEnter (Collision col)
{
FMODUnity.RuntimeManager.PlayOneShotAttached ("event:/EVENTNAME", gameObject);
}
Put that into a blank C# script inside the class, attach that script to a gameobject that falls and it should play an FMOD event when it lands.
If you have any trouble with this, feel free to get back to me and I'll try and help some more. Thanks for the comment and best of luck with your studies! Oh I also made a video talking about collision sounds sot hat might help you out: ua-cam.com/video/pVzgjleibQo/v-deo.html
=D
@@ScottGameSounds wow many thanks for that quick and detailed response! That's absolutely awesome and helps a lot!
Hi scott, thanks for you videos tutorial !
If you have time to answer someday I would like to know if you know how to change key control on the game and replace it with the arrows keys..
Thanks in advance man
I don't really know how I'm afraid. In your Unity project I know you can go to Edit -> Project Settings -> Input. From there you can open the 'Vertical' and 'Horizontal' tabs. I think this is where you fill out which buttons you want to control your player with. It might be set up slightly different for the 2d game kit though. Sorry I can't be much more help PICCIRILLI.
@@ScottGameSounds Hey man ! Thanks a lot for your reactivity, I will try this ! :)
Anyway, can I abuse of your kindness, did you had this problem with the platform won't move when you jump on, I try to find something on unity forum , they talk about "reset" the rigidbody2D" but nothing works for me.
no worries if you don't know
thanks !
what programming language you using ?
C#
@@ScottGameSounds can python be used ?
@@miguel1waterpolo1guy I don't think so unfortunately. Unity is built primarily on C# and the scripts you create all use it too.
@@ScottGameSounds so in short . F mod and wwise use scripts of the game engines language like c#??.. sorry for the noob question , I'm really interested in the sound engineer of games and I know some languages like c++ and python. Are there no python game sound tools ?
@@ScottGameSounds just so I can understand better , say I had a friend make a game and send it to me. Can i then unpack the game in fmod and edit it or do you need to make the game yourself and then unpack in fmod
Bruh…