Hello!!
We are currently making a 2D fighting game, but we don’t know how to put a winning scene for the winner. Can one please share there knowledge on this topic. Thank you very much ,Hello We are currently making a 2D Fighting Game, we are new to this and we don’t know how to put the scene for winning player after there opponent hits its HP to Zero. Can anyone pls share there knowledge to it. Thank you
This is all to do with what is called Scene Management. At the top of the File > Build Settings window, you add all the scenes that you want in your game. You’ll notice that each scene has a number to its right. You can refer to a scene either by its name or by its number (called Scene Build Index). You’ll also need to add a new namespace – see the code example for that.
You’d typically use the Scene Build Index if you have a lot of scenes that must run one after the other (like a puzzle game where you go through puzzle 1, puzzle 2 etc). For games where scenes are non-linear or when you want to do a game over, you’ll typically use scene name.
using UnityEngine;
using UnityEngine.SceneManagement;
public class ExampleClass : MonoBehaviour
{
void GameOver()
{
SceneManager.LoadScene("Game Over Scene");
}
}