Characters appear in fight screen after character selection?

I am creating a classic street fighter game. I did the character selection, but how can I load in the character images of the characters selected when the scene transitions to the fight arena? Thank you.

Heya :slight_smile:

For this kind of thing, I always create a c# script called something like “static_variables”, which is never placed on any object in any scene, but instead just kind of exists in the project as a whole. Also for this, you must remove the “: MonoBehaviour” after the class name, as it’s not something that takes action on anything and doesn’t use any functions within monobehaviour.

Next, store which two characters were selected in this script at your selection screen. I’ll be using two integers to represent the characters (let’s say blue guy is 7 and red guy is 8).

public class PickingCharacterScreen : MonoBehaviour {
   void PickCharacters () {
        //do some fancy magic that lets the player pick their character, let's pretend we picked 7 //and 8
        Static_Variables.lastChosenPlayer1 = 7;
        Static_Variables.lastChosenPlayer2 = 8;
        //note that we don't need a reference to Static_Variables, as it's a public class that isn't monobehaviour

//a different script
public class Static_Variables { //notice we removed the MonoBehaviour word here
   public int lastChosenPlayer1 = 0;
   public int lastChosenPlayer2 = 0;

Okay, great. Now, when you load up the fighting scene, you need to get those ints to know which players to spawn. that’s as simple as setting it.

public class FightingScene : MonoBehaviour {
  void SpawnPlayers () {
    int player1 = Static_Variables.lastChosenPlayer1;
    int player2 = Static_Variables.lastChosenPlayer2;
    //spawn your characters now that you know which ones you want