Topic: KO anounce

a ko sign is very common in basically every fighting game out there, but just recently i've come across the fact that UFE doesn't show a KO message or SOUND when a character is defeated...

so, i wanted to know, how could it be implemented?

Thanks!

Me encontraste en un negro camino como un peregrino sin rumbo ni fe, pero la luz de tus ojos divinos cambió mi suerte por dicha y placer.

Re: KO anounce

Hmm, this is probably the one thing I would think any method is viable!  Off the top of my head, here's some ways to do it:

  1. Create an announcer variable for KO and/or create KO language; then fire an alert for each when the last hit is done

  2. Create a GUI for KO, but you'll also need to create the GUI Screen prefab and corresponding code (a fair bit of work), then to also call the screen up at round end

  3. Similar to Option 2, but instead of making it a new GUI screen, attach it to Battle GUI prefab and just use the Battle GUI script to enable it on round end (disable it at round start).

I would say Option 3 is the best method, possibly with the announcer from Option 1.  It will give you the most control over how the KO message looks, and requires the least code to get working.  With some gusto, you might even be able to animate it...

Share

Thumbs up +1 Thumbs down

3 (edited by shubi 2015-08-12 02:49:32)

Re: KO anounce

Here is what I did to have a K.O.-text and soundfile in our game.
Maybe it's not the best way, but it works wink


At first open up "GlobalInfo.CS" to create a variable for the K.O.-text and K.O.-soundfile:


after
   

public string timeOver = "Time Over";
public string perfect = "Perfect!";
public string rematch = "Rematch";
public string quit = "Quit";

 
add this: 
   

public string kotext = "K.O.";    

 
next edit in the same file:
 
after:
   

public AudioClip firstHit;
public AudioClip counterHit;
public AudioClip parry;
public AudioClip timeOver;

 
add this: 
   

public AudioClip kosound;     

    ...
 
Now go to your UFE.config file and select GUI-options -> Screens -> Battle GUI (open)
Assign a soundfile to the new AudioClip-field:

http://s17.postimg.org/dpa0zklgf/ko_1.jpg

Open up "GlobalEditorWindow.cs":

after:

globalInfo.languages[i].rematch = EditorGUILayout.TextField("Rematch:", globalInfo.languages[i].rematch);
globalInfo.languages[i].quit = EditorGUILayout.TextField("Quit:", globalInfo.languages[i].quit);

add this:

globalInfo.languages[i].kotext = EditorGUILayout.TextField("K.O.:", globalInfo.languages[i].kotext);          

Now you can set the text-string for the K.O.-message by changing the setting in the UFE.config:

http://s17.postimg.org/ha5wispzz/ko_2.jpg


Next edit the UFE.cs-file:

after:

public static GameObject gameEngine{get; protected set;}
public static bool gameRunning{get; protected set;}
public static bool synchronizedRandomSeed{get; protected set;}

           
add this:         

public static bool koflag = 0;


Next edit the ControlScript.cs:

after this:

if (myInfo.currentLifePoints == 0){
            UFE.PlaySound(myInfo.deathSound);

add this:

                            UFE.koflag = true;
                        

           
This will set the K.O.-flag to "true" if someone gets knocked out.


Now open your DefaultBattleGUI.cs

After:

    public override void DoFixedUpdate (){
        base.DoFixedUpdate ();

        if (this.isRunning){
            AbstractInputController p1InputController = UFE.GetPlayer1Controller();
            AbstractInputController p2InputController = UFE.GetPlayer2Controller();
            float deltaTime = Time.fixedDeltaTime;

     
Add:

   //**************** K.O.-text and sound *************************
            if (UFE.koflag == true) 
            { 
                UFE.koflag = false;
                UFE.PlaySound(this.announcer.kosound);
                this.OnNewAlert(UFE.config.selectedLanguage.kotext, null);
            }

If you want to add your custom K.O.-animation/text you can also spawn it in the code snippet above.

Finally add after:

protected override void OnRoundBegin(int roundNumber){
        base.OnRoundBegin(roundNumber);

This:

UFE.koflag = false;


Here is a quick video how it looks ingame:

[media]https://youtu.be/IIMKLyAb-64[/media]

Good luck, I hope it works for you smile

shubi's Website

Share

Thumbs up +4 Thumbs down

Re: KO anounce

shubi wrote:

Here is what I did to have a K.O.-text and soundfile in our game.
Maybe it's not the best way, but it works wink

This is such a great tutorial I'll just move the entire topic to Tips & Articles.

Thanks shubi smile

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.
Don't forget to check our discord channel.

Re: KO anounce

works great! thanks!

Me encontraste en un negro camino como un peregrino sin rumbo ni fe, pero la luz de tus ojos divinos cambió mi suerte por dicha y placer.

Re: KO anounce

This works really well thanks.  However when the round is over the CPU will still beat on the opponent for a short while which causes multiple "KO" sounds being played.  Is there a way to make the winner unable to input anything as soon as the KO flag is true?

Share

Thumbs up Thumbs down

7 (edited by shubi 2015-08-12 02:37:26)

Re: KO anounce

Kandy_Man wrote:

This works really well thanks.  However when the round is over the CPU will still beat on the opponent for a short while which causes multiple "KO" sounds being played.  Is there a way to make the winner unable to input anything as soon as the KO flag is true?

EDIT: Updated the code to solve that problem

shubi's Website

Share

Thumbs up +2 Thumbs down

Re: KO anounce

shubi wrote:
Kandy_Man wrote:

This works really well thanks.  However when the round is over the CPU will still beat on the opponent for a short while which causes multiple "KO" sounds being played.  Is there a way to make the winner unable to input anything as soon as the KO flag is true?

To solve that problem, I changed the code a little bit. The KO-flag variable has now three different states:

The flag will be set to "1" after the first K.O.-hit and the K.O.-sound will be played. After that, the flag will be set to "2", so it's not possible to play a K.O.-sound again, as long as the flag isn't set to "0".
Don't forget to set the flag to "0" at the beginning of each round.

Thanks for the reply.  I  managed to fix it by locking input and movement in the same section that sets the flag back to false.  I can't figure out how to change how soon the Perfect/Winner alert appears or I'd just shorten that to lock it all.  I'll remember your method though as I can imagine we might want input and movement to still be checked if someone is in the middle of a combo or something.

Share

Thumbs up Thumbs down