Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Best way to change scenes using Soomla Level up?

Discussion in 'Game Design' started by ano1234, Jan 10, 2015.

  1. ano1234

    ano1234

    Joined:
    Dec 26, 2014
    Posts:
    1
    To preface, I'm new to game development but not new to programming.

    Currently in the game I am creating, when the player enters a trigger at the end of the level I call Application.LoadLevel(Application.loadedLevel+1); to change to the next level. And to keep track of completed levels, I only save the number of the highest level completed something like maxLevelCompleted +=1; of course I could always keep a bool array for this as well but I felt it was not necessary.

    My question is, how do I bring Soomla level up into this or what is the best way in general for handling changing scenes and monitoring completed levels? In Soomla each level has an id so I'd have to call things like level1.Complete() but in my example from above I have this written once in the player class. Soomla level up has functionality that I would like to use, I just don't quite understand how its concept of levels tie in with scenes.
     
  2. gurdotan

    gurdotan

    Joined:
    Feb 6, 2013
    Posts:
    15
    SOOMLA LevelUp is designed to play alongside with Unity's core classes and methods, not as a replacement. In that sense, if you're using Unity's API and you want to benefit from LevelUp as well, you'll have to use code from both. You are right to point out that LevelUp requires defining all levels with unique string IDs. The Application.LoadLevel method accepts either an integer of the level index or a string of the level name. So one workaround that would keep your code simple would be to define Levels with LevelUp that have IDs "0", "1", "2"... And then you can use these IDs in order to complete levels with the LevelUp API:

    // Define worlds, levels, gates, missions, scores, rewards.
    ...
    SoomlaLevelUp.Initialize(mainWorld);

    Level level1 =
    level1.Start();
    ...
    ...
    ...
    // When the player completes the level successfully
    // end it, passing the true flag.
    level1.End(true);


    To make your life easier, you can define batches of levels quickly with the BatchAddLevelsWithTemplates method:

    mainWorld.BatchAddLevelsWithTemplates(
    10, // Number of levels in this world
    someGate, // Gate for each of the levels
    new List<Score>() { ... }, // Scores for each of the levels
    new List<Mission>() { ... } // Missions for each of the levels
    );


    Make sure you use the GameObject.DontDestroyOnLoad method when moving between scenes
     
    theANMATOR2b likes this.