Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Discussion Game Development 2D Turn Based - Professional Dev

Discussion in 'Scripting' started by WDLG_RobertIV, May 26, 2024.

  1. WDLG_RobertIV

    WDLG_RobertIV

    Joined:
    Mar 29, 2024
    Posts:
    1
    hi, I'm professional video game developer and indie game dev Robert IV. I've worked on some titles you may have heard off, From Final Fantasy to Pokemon. i was scanning around Unity because my new game IP is being done in Unity and i thought that my experience may be off some use.

    i get people adding me a lot on Steam with the same question of how to do this, How to do that, When most of the time the answer is not actually the problem but in how you do it.

    i like to try to get people to think differently when making video games, i was recently asked about how to do a turn based system in Unity by some people who follow me still. They said they where using switches. I thought i'd take the chance to explain to you how to look at things differently in game development.

    When i hear the term "turn" based i don't think about switches or turn based systems that exist as an actual concept in a game engine, But rather i start thinking about my own way to create such a system.

    "Turn based" is just a term used for when multiple things will be taking turns to execute an action. However there is no set way of how these turns should be calculated. Here is an example.

    Code (CSharp):
    1.   private enum Phases { PlayerTurn, AITurn, CheckResults}
    2.   private Phases currentPhase;
    3.  
    4.   void Start()
    5.   {
    6.       currentPhase = Phases.PlayerTurn;
    7.   }
    8.  
    9.   private void Update()
    10.   {
    11.       switch(currentPhase)
    12.       {
    13.           case Phases.PlayerTurn:
    14.               Debug.Log("Give player turn");
    15.               break;
    16.           case Phases.AITurn:
    17.               Debug.Log("Give player turn");
    18.               break;
    19.           case Phases.CheckResults:
    20.               Debug.Log("Give player turn");
    21.               break;
    22.       }
    23.   }
    Which is fine however, It is important to note that this is also fine.

    Code (CSharp):
    1.  
    2.     void Start()
    3.     {
    4.         GivePlayerTurn();
    5.     }
    6.  
    7.     void GivePlayerTurn()
    8.     {
    9.  
    10.     }
    Notice that when game developing it is important to think about how something works for your game. just because somebody else made a cool character moving script for example might not be good for you. I mean you wouldn't put Tidus's script from FFX onto pacman would you.

    So I just like to help people get them to think about creating things in their way, There is no such thing as a "turn based" system, It doesn't exist. it can only exist when something makes it exist.

    Code (CSharp):
    1.    private GameObject playerControlUI;
    2.  
    3.    void Start()
    4.    {
    5.        GivePlayerTurn();
    6.    }
    7.  
    8.    void GivePlayerTurn()
    9.    {
    10.        playerControlUI.SetActive(true);
    11.    }
    12.  
    13.  
    14.    IEnumerator AIBrain()
    15.    {
    16.        //some ai choosing of actions
    17.        yield return new WaitForSeconds(Random.Range(0,10));
    18.        //this ending time would give the impression an ai is choosing something or "thinking"
    19.        //Execute actions
    20.        yield break;
    21.    }
    22.  
    23.    void RemovepPlayercontrol()
    24.    {
    25.        playerControlUI.SetActive(false);
    26.    }

    So you see how no system existed then you start creating this whole system yourself. it's up to you who gets to decide what is right or wrong in your game. There is no right or wrong answer. Only did it break or not break lol

    i hope this helps you understand how a change of thinking can achieve the same result but in a way you want to absorb the information. Which may not have been the way you were told. I hope this give you a bit of insight into how professional game devs look at things and I hope you get inspired.

    There is no one right way in game development to achieve a result. There is millions of ways. I only posted this up because quite a few people have come to me asking about turn based in Unity like pokemon from unity communities etc and so i came here to drop some information on that.

    So there is no such thing as turn based, Turn based is an essence of time created by you, Doesn't matter if its physics based, time based, ui based whatever, it's just about what is supposed to happen and when. Which can theoretically be anything.

    Have a lovely day. By the way don't expect me to post ever again I don't use Unity forums etc lol not that there's anything wrong with them just busy always busy