Topic: How To Create Level Selection System In UFE?

I want to create level selection system but don't know how to create it anyone here who do this task? Need help

Share

Thumbs up Thumbs down

Re: How To Create Level Selection System In UFE?

Have you watched this video tutorial yet?
https://youtu.be/oMM1FC3eueo

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: How To Create Level Selection System In UFE?

Yes I watch this series but I need to do some different thing. The task i need to do is to create Level Selection Screen In main main menu Or UI Scene. Can you please play this game. Then you better understand what I want to do


https://play.google.com/store/apps/deta … hting.game

the reference game

Share

Thumbs up Thumbs down

4 (edited by osamamasood26 2022-11-17 08:00:13)

Re: How To Create Level Selection System In UFE?

https://youtu.be/hGMs5_aaaD0?t=181

How Can I Create Level Selection Like this in UFE.
Kindly guide me
And also tell me how can I save the player for every time I open game

Share

Thumbs up Thumbs down

Re: How To Create Level Selection System In UFE?

Humm, there is just so much we can offer in terms of support. You must do some of the work yourself.

That said, if you don't want to work on top of the UI templates you can choose to use different deployment modes (http://www.ufe3d.com/doku.php/global:deployment) to start the game directly. This is useful for situations where you want to develop your own user interface (such as a map or even an entirely different game) and just load the UFE scene for the actual fighting game part.
For example, you can create a script like this:

using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadUFE : MonoBehaviour
{
    public UFE3D.CharacterInfo player1Char;
    public UFE3D.CharacterInfo player2Char;
    public string stageName; 

    public void LoadUFECharactersAndStage()
    {
        UFE.SetPlayer(1, player1Char);
        UFE.SetPlayer(2, player2Char);
        UFE.SetStage(stageName);

        SceneManager.LoadScene("UFEBattleScene");
    }
}

And have this script loaded in the scene you want (map for example). Now, create a scene called "UFEBattleScene", have UFE loaded and have its deployment type set to "Versus Mode". In your map scene, you can now dynamically change the values for character or stage and UFE should load those up in the new scene.
Make sure you also study how to exit the scene using the OnGameEnds event or "VersusModeAfterBattleScreen" prefab.

For more on coding, check out this page:
http://www.ufe3d.com/doku.php/code

PS: This can be done using any of UFE licenses (no Source required).

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: How To Create Level Selection System In UFE?

Okay. Would you please tell me How can I get fight index of story mode?

Share

Thumbs up Thumbs down

Re: How To Create Level Selection System In UFE?

Sure:

// The index of the current "group"
UFE.storyMode.currentGroup = 0;
// The index of the current "battle" in the current "group"
UFE.storyMode.currentBattle = 0;
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: How To Create Level Selection System In UFE?

Mistermind wrote:

For example, you can create a script like this:

using UnityEngine;
using UnityEngine.SceneManagement;
.
.
.

Just a correction on the code example (for anyone reading this post):

using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadUFE : MonoBehaviour
{
    public UFE3D.GlobalInfo globalConfigFile;
    public UFE3D.CharacterInfo P1SelectedChar;
    public UFE3D.CharacterInfo P2SelectedChar;
    public int selectedStage;

    public void LoadUFECharactersAndStage()
    {
        globalConfigFile.deploymentOptions.deploymentType = UFE3D.DeploymentType.VersusMode;

        globalConfigFile.deploymentOptions.activeCharacters[0] = P1SelectedChar;
        globalConfigFile.deploymentOptions.activeCharacters[1] = P2SelectedChar;
        globalConfigFile.deploymentOptions.AIControlled[0] = false;
        globalConfigFile.deploymentOptions.AIControlled[1] = true;

        globalConfigFile.selectedStage = globalConfigFile.stages[selectedStage];

        SceneManager.LoadScene("Demo_Fighter2D");
    }
}

This code allows you to load UFE dynamically from another scene, skip the UI interface and go straight to versus mode.

Example:
https://i.ibb.co/h1TSVxX/image.png

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: How To Create Level Selection System In UFE?

Mistermind can you elaborate a bit on how you would transition back to the non-UFE scene after the battle ends? I tried putting a call to SceneManager.Load() in UFE.OnGameEnd or in DefaultVersusModeAfterBattleScreen.OnShow, and in either case when my non-UFE scene tries to start the UFE battle a second time it crashes with:

MissingReferenceException: The object of type 'Image' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
DefaultBattleGUI.OnGameBegin (ControlsScript cPlayer1, ControlsScript cPlayer2, UFE3D.StageOptions stage) (at Assets/UFE/Engine/Scripts/UI_Templates/DefaultBattleGUI.cs:381)
UFE.FireGameBegins () (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
UFE._StartGame (System.Single fadeTime) (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
UFE.StartGame (System.Single fadeTime) (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
UFE3D.LoadingBattleScreen.StartBattle () (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
FluxCapacitor.ExecuteLocalDelayedActions () (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
FluxCapacitor.ApplyInputs (System.Int64 currentFrame) (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
FluxCapacitor.DoFixedUpdate () (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)
UFE.FixedUpdate () (at <aa04d077bee7445887c4a4ca47e6a2bb>:0)

The code to load the UFE scene is just

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class CustomDeploy : MonoBehaviour
{
    public UFE3D.GlobalInfo globalConfigFile;
    public UFE3D.CharacterInfo P1SelectedChar;
    public UFE3D.CharacterInfo P2SelectedChar;
    public int selectedStage;

    public void LoadUFECharactersAndStage()
    {
        globalConfigFile.deploymentOptions.deploymentType = UFE3D.DeploymentType.VersusMode;

        globalConfigFile.deploymentOptions.activeCharacters[0] = P1SelectedChar;
        globalConfigFile.deploymentOptions.activeCharacters[1] = P2SelectedChar;
        globalConfigFile.deploymentOptions.AIControlled[0] = false;
        globalConfigFile.deploymentOptions.AIControlled[1] = true;

        globalConfigFile.selectedStage = globalConfigFile.stages[selectedStage];

        SceneManager.LoadScene("Demo_Fighter2D");
    }
}

This is an example of how I'm transitioning back to the non-UFE scene in OnGameEnd:

    public class Transitioner : MonoBehaviour
    {
        private void Start()
        {
            UFE.OnGameEnds += UFEOnOnGameEnds;
        }
        
        private void UFEOnOnGameEnds(ControlsScript winner, ControlsScript loser)
        {
            SceneManager.LoadScene("Main");
        }
    }

It seems to me like there is some static state in UFE that is carried over from the first time "Demo_Fighter2D" is loaded, but I can't figure out how to clean that up so subsequent loads work right.

Share

Thumbs up Thumbs down

Re: How To Create Level Selection System In UFE?

Ahah! I figured it out. You have to call UFE.EndGame() in order to rest all the static stuff going on in the engine. So for example

    public class Transitioner : MonoBehaviour
    {
        private void Start()
        {
            UFE.OnGameEnds += UFEOnOnGameEnds;
        }
        
        private void UFEOnOnGameEnds(ControlsScript winner, ControlsScript loser)
        {
            UFE.EndGame();
            SceneManager.LoadScene("Main");
        }
    }

Works fine!

Share

Thumbs up +1 Thumbs down

Re: How To Create Level Selection System In UFE?

I tried this method:

globalConfigFile.selectedStage = globalConfigFile.stages[selectedStage]; 

But there seems to be some sort of issue with the stage selection system. I enter the integer for my second stage which is 1, but UFE just loads the first stage at the 0th position in the config file.

I have also tried the following method and passed the string value:

UFE.SetStage(selectedStage);

But still the issue persists.

Mistermind wrote:
Mistermind wrote:

For example, you can create a script like this:

using UnityEngine;
using UnityEngine.SceneManagement;
.
.
.

Just a correction on the code example (for anyone reading this post):

using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadUFE : MonoBehaviour
{
    public UFE3D.GlobalInfo globalConfigFile;
    public UFE3D.CharacterInfo P1SelectedChar;
    public UFE3D.CharacterInfo P2SelectedChar;
    public int selectedStage;

    public void LoadUFECharactersAndStage()
    {
        globalConfigFile.deploymentOptions.deploymentType = UFE3D.DeploymentType.VersusMode;

        globalConfigFile.deploymentOptions.activeCharacters[0] = P1SelectedChar;
        globalConfigFile.deploymentOptions.activeCharacters[1] = P2SelectedChar;
        globalConfigFile.deploymentOptions.AIControlled[0] = false;
        globalConfigFile.deploymentOptions.AIControlled[1] = true;

        globalConfigFile.selectedStage = globalConfigFile.stages[selectedStage];

        SceneManager.LoadScene("Demo_Fighter2D");
    }
}

This code allows you to load UFE dynamically from another scene, skip the UI interface and go straight to versus mode.

Example:
https://i.ibb.co/h1TSVxX/image.png

Share

Thumbs up Thumbs down

Re: How To Create Level Selection System In UFE?

Set Up Your Game Levels:

First, ensure that you have multiple game levels or scenes created in Unity, each representing a different level in your game.
Create a UI Canvas:

In Unity, create a UI canvas if you haven't already. This canvas will house your level selection menu.
Design the Level Selection Menu:

Design your level selection menu using UI elements like buttons or images. Each button should represent a different level in your game.
Add Button Functionality:

Attach scripts to each level button to handle their functionality. You can create a custom script to manage level selection or use Unity's built-in UI Button component.
Load Levels On Button Click:

Implement code that loads the corresponding level when a button is clicked. You can use the SceneManager.LoadScene method to load different scenes.
csharp
Copy code
using UnityEngine.SceneManagement;

public void LoadLevel(string levelName)
{
    SceneManager.LoadScene(levelName);
}
Set Up Level Unlocking (Optional):

If you want to unlock levels as the player progresses, you'll need to implement a system for tracking progress and unlocking levels accordingly. This can involve saving and loading player progress data.
Display Level Status (Optional):

You can also display the status of each level, such as completed, locked, or unlocked. This may involve creating custom UI elements or using UI text to display level information.
Test Your Level Selection System:

Test your level selection system thoroughly to ensure that each button correctly loads the associated level.
Polish and Enhance:

Add visual feedback, animations, and any additional features to make your level selection menu user-friendly and visually appealing.
Optimize and Debug:

Optimize your code and UI for performance and debug any issues that arise during testing.
Documentation:

Document your level selection system and any custom scripts you've created for future reference and collaboration with your team.
Publish and Distribute:

Once you're satisfied with your level selection system, build and distribute your game to your desired platforms.

Share

Thumbs up Thumbs down