Search Unity

FSM : one scene for each state?

Discussion in '2D' started by Biktor, Jul 28, 2014.

  1. Biktor

    Biktor

    Joined:
    Apr 10, 2014
    Posts:
    7
    I'm a noob with Unity who came from Air / Starling.
    I want to implement a FSM for game structure and after had read many tutorials, I have a doubt.

    My game target is iOS / Android and some tutorials does one scene for each state, but Is this good strategy for mobile development?
    Maybe I'm wrong but I'm thinking that is bad for performance.

    Is it a good approach one scene for each state?
    Are there some alternative more efficient?

    Thank you.
     
  2. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    The term "state" is very general, so it might help if you were more specific. It sounds like you're talking about using states for different "screens"? Like menu screens?

    You could try it and see how it goes. Sometimes optimizing when you don't really need to is a waste of time. But if you do run into performance issues, you can draw "screens" by making your UI elements active or inactive. So if you had an Options state, maybe you'd activate a parent GameObject that contained all of your Options UI and inactive everything else.

    Often an FSM has a place to put "I'm entering this state" code. So you could do that there for each UI state.

    I ended up writing my own screen manager that works with NGUI to make that sort of thing easier, which could be overkill depending on how complex your UI is.

    The only mobile game I've done only uses a single scene. There's an FSM to manage what to do when.
     
  3. Biktor

    Biktor

    Joined:
    Apr 10, 2014
    Posts:
    7
    First of all, thank for your reply.

    Yes, when I said " scene" I'm talking about one scene contains UI and other scene contains the game. Anyway, your reply is very helpful, I think the best approach are Game Objects instead scenes, and activate or not.

    Thank you very much again.