Making the announcer say character's name depending on what character you choose [SOURCE ONLY]
Continuing with the GUI announcer voices, this time we'll make our announcer say our character's name when we pick it. It doesn't need to be the announcer though. It can be the character saying something or anything you like. To do this, you need the SOURCE version of UFE.
[media]https://www.youtube.com/watch?v=ah_iOIli6Vw[/media]
We are editing a lot of core scripts in this tutorial, so be extra careful. We will start up by editing the CharacterInfo.cs located under UFE/Scripts. On line 53 is public AudioClip deathSound; This sound is called when your character gets KO'ed. We are going to make a similar audio clip, but use it in a different way. Add a new empty line after the deathSound and write this on it:
public AudioClip selectSound;
We have now created a new audio clip for the character info, but we still need to edit CharacterEditorWindow.cs (located under UFE/Editor) to be able to add the sound on our Character asset. Again we'll use the death sound as an example. Death sound is located on line 191 and looks like this: characterInfo.deathSound = (AudioClip) EditorGUILayout.ObjectField("Death Sound:", characterInfo.deathSound, typeof(UnityEngine.AudioClip), false); Using this example, we'll make a new line after the death sound and put in code for our sound. It all comes on the same line, even though it doesn't fit on the same line on the forums:
characterInfo.selectSound = (AudioClip) EditorGUILayout.ObjectField("Select Sound:", characterInfo.selectSound, typeof(UnityEngine.AudioClip), false);
If you have done everything correct so far, you should now have new option in the character editor. Drag and drop your sound clip on the Select Sound field:
So now we have the selection sound, but we are not ready yet. Our sound still needs to be used somewhere. For that we'll edit CharacterSelectionScript.cs located under UFE/Scripts. This piece of code is on lines 110-112:
if (Input.GetButtonDown(UFE.GetInputReference(selectButton, UFE.config.player1_Inputs))){
UFE.PlaySound(selectSound);
UFE.SetPlayer1(UFE.config.characters[p1HoverIndex]);
What this code basically does is: Set Player 1 character and play sound effect, if he presses select button (T by default). We will add our announcer sound clip here too. Create an empty line after that part of the script and add this on it:
UFE.PlaySound(UFE.config.player1Character.selectSound);
Scroll down a bit an around line 121 you will see player 2 version of the same code. You should now be able to do this part by yourself (same as player 1, just change code to player2Character.selectSound. Now the sound clip should play when you pick your character. Reply this thread, if you have any problems with it!