1 (edited by Miggoh 2014-04-05 03:50:13)

Topic: Miggoh's UFE tutorials

I will post here tutorials every time I make something useful for my project. Tutorials will work on any version of Universal Fighting Engine unless they are tagged with [SOURCE ONLY]. Tutorials are always compatible with the free version of Unity.

List of tutorials:

User Interface:

Share

Thumbs up +2 Thumbs down

Re: Miggoh's UFE tutorials

Playing other sounds in the title or character select menu than music

Do you want to play a sound effect when player goes to your title screen? Such as the name of your title? How about saying "choose your character" in the character select screen? This can be achieved with some easy UFE coding.

[media]http://youtu.be/rfcoEaoRDgk[/media]

Start by creating a new C# script (right-click, create, C# script). You can also use this script I made and import it to your project.

Rename the script as "MenuSoundScript.cs" and open the script in MonoDevelop (or your script editor of choice) and type in:

using UnityEngine;
using System.Collections;

public class MenuSoundScript : MonoBehaviour {

public AudioClip introSound;

void Start () {
UFE.PlaySound(introSound);
}
}

Next go to your GUI prefabs folder (UFE/GUI/prefabs) and drag and drop your script on any of the prefebs in the inspector (obviously the one you want to add the sound clip on). Then drag and drop any audio file in the "Intro Sound" field. Now it should be working as intended and your prefab should be looking something like this:

http://dl.dropboxusercontent.com/u/223629633/introscreenprefab.png

Educational

What does the script do?

In short:
First we make a new class called MenuSoundScript (class name must match with the script's file name) then we add a public audio clip called Intro Sound, so we can set a sound for our script to play. Then we use void to specify that our Method (Start) will return no value.

UFE.PlaySound is part of the UFE script. It plays a sound effect on the main camera at current sound level. Will only be played, if sound effects are enabled in the options menu.

Share

Thumbs up +2 Thumbs down

Re: Miggoh's UFE tutorials

Thanks for this, I'm a noob to Unity and stuff like this helps a lot big_smile

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

Wow thanks miggoh this will be very helpful to those of us who lack programming skills

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

I see you are working on some amazing tutorials. All things that I really needed. If I may suggest 1 tutorial could you create one where it shows how to increase the character limit to show on the character select screen.

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

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:

https://dl.dropboxusercontent.com/u/223629633/AOI.png

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!

Share

Thumbs up +1 Thumbs down

Re: Miggoh's UFE tutorials

J.S.B wrote:

I see you are working on some amazing tutorials. All things that I really needed. If I may suggest 1 tutorial could you create one where it shows how to increase the character limit to show on the character select screen.

I'll take a look at it today. If I remember right, that can be done pretty easily from the GUI scripts.

Share

Thumbs up +1 Thumbs down

Re: Miggoh's UFE tutorials

Cool! Do you thik Daniel will eventually incorporate these scripts officially in his engine? It would be cool because when he updates the game we wouldn't have to manually update the scripts our selves.

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

Miggoh wrote:
J.S.B wrote:

I see you are working on some amazing tutorials. All things that I really needed. If I may suggest 1 tutorial could you create one where it shows how to increase the character limit to show on the character select screen.

I'll take a look at it today. If I remember right, that can be done pretty easily from the GUI scripts.

something around 12 to 14 character select slots would be cool

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

You can add new rows or columns on the CharacterSelection prefab. It's located under UFE/GUI/prefabs. Problem with this is that any extra character slots won't fit on the screen because of the big character portraits. So the method for adding more slots depends on how you want your GUI to look (smaller character select slots or smaller portraits, etc.). You can edit the character selection data in the CharacterSelectionScript.cs located under UFE/Scripts (in source edition).

Share

Thumbs up +1 Thumbs down

Re: Miggoh's UFE tutorials

cool!

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

Miggoh did you ever finish the video splash screen tutorial?

Re: Miggoh's UFE tutorials

Hey there, Miggoh. I seem to have gotten the first part of the select sound down pat. BUt the only difficulty I have is finding the last code within the CharacterSelectionScript.cs file.

if (Input.GetButtonDown(UFE.GetInputReference(selectButton, UFE.config.player1_Inputs))){
                UFE.PlaySound(selectSound);
                UFE.SetPlayer1(UFE.config.characters[p1HoverIndex]);

I have the Source version of UFE and I was wondering what I'm doing wrong. Any help will be greatly appreciated.

Share

Thumbs up Thumbs down

Re: Miggoh's UFE tutorials

This tutorial was written well before the 1.5 update, so that's an old reference. 

That bit is now in its own function called: OnCharacterSelected().  You should be able to figure it out from there wink.

NOTE: in 1.6 this will likely change again as we had to support the new uGUI.

Share

Thumbs up Thumbs down