Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Daily Events and content changes

Discussion in 'Scripting' started by EdoC-QWERTY, May 11, 2021.

  1. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    71
    Hello,
    I want to add some daily event in my game.
    It's a puzzle game with a normal level progression system. After level 1 is completed, level 2 in unlocked and so on.
    But I wanted to add some bonus levels that would change daily, so players have only 24hours to complete them to get an achievement.
    After 24 hours the bonus level changes. It would be like a daily time event.

    The problem is that in my game every level is in a different scene. So I would have to create one different level a day and publish a new update with the new level.

    I obviously don't wanna do this, since it would require to submit a different app version to Google Play every day.

    How can I do this?

    The first idea that came into my mind is that I include like 7 additional levels in the build and then every 24 hours I change the bonus level to be one of those pre loaded levels.
    I would have to update a new version every week, if I put 30 levels in the build, once a month but

    Is there another way to achieve this?

    Thanks in advance
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,823
    I haven't done this, but it should be possible to download scenes from a server and then load them dynamically. I believe the current recommended approach is to use Addressables.
    https://learn.unity.com/tutorial/addressables-scene-loading

    You can probably also do this using asset bundles.


    Of course, it would probably be more efficient if you created your own way to serialize and deserialize custom puzzles without using a separate scene for each one. But that might be more work.
     
    EdoC-QWERTY and Brathnann like this.
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    6,598
    Yep, depending on how your game is structured and what is needed for a level, you either need to look into asset bundles that you can download, or some sort of data structure that determines what the layout of your level is and is a simple json file or such that you can download.

    Example, we have a word search game out and I just upload a list of words that covers a month and is a simple json file. The scene itself grabs that list and populates the puzzle. I never have to do a new game build and the json file is small.

    From experience if a player has to download an update once a week or a month, you'll lose players. Also, you have no guarantee how quickly Google or Apple will approve an update, so you need to look into addressables, which does use asset bundles, just in a much better way.
     
    EdoC-QWERTY likes this.
  4. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    71

    Thank you both for the replies.

    I will look into Addresables and how to use them, but then there is another problem, I have zero knowledge on how to run a server and make my app download new data everyday..

    Could you guys suggest me some tutorials on those topics as well?

    My levels are complicated from my little experience with Unity. I don't think I can desterilize / serialize them with simple json or other files.
    There are a lot of objects in the scene and many different prefabs that have more child objects.

    The reason why I have different scenes for every level is that I use the Unity Tilemap with around 100 different Tile sprites.
    So even if some prefab are the same across the game, the Tiles layout is different every level.
    I don't know if I explained myself, if you are curious the game it's called DOTsZLE on Google Play.

    Thanks again.
     
  5. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    71
    Hey @Brathnann you said you were already using addressables so I would like to ask you some more tips.

    I looked up Unity tutorials about addressables and already started to re-structure my project to use of them(I have a back up from the previous build obviously).

    Now I need to choose an hosting service. What hosting service are you using? Can you suggest me one? (google cloud, amazon, microsoft)


    As a solo developer I would like something free, but obviously all the free subscriptions to these services have limits on how many data and download are used per month.
    My concerns is that if i choose one of these services and my playerbase increases(It's not likely to happen but who knows) I will have to pay for those services and since I can't afford that at the moment, users will not be able to play my game.

    Do you have any other tips about these concerns?

    Thank you.
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    6,598
    The free options might help at the start if you're short on funds. That might help you get through until the game generates some income.

    We use keyCDN for a huge chunk of our stuff. However, you do have to pay $49 when you need to add credits. I'm not sure if they still do this, but credits use to expire after a year. But that might be enough for you for now.

    I'm not aware of any unlimited free option.
     
    EdoC-QWERTY likes this.
  7. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    71
    Thank you.

    While looking into the matter myself I found this thread.

    https://forum.unity.com/threads/using-addressables-along-with-google-play-asset-delivery.905831/

    It seems that it's possible to use addressable with Google Play asset delivery.
     
    Brathnann likes this.
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    25,851
    Whatever you do I highly recommend staying away from writing code to pluck individual pieces and chunks out of an asset bundle and putting it into your game at runtime.

    The reason: there are a staggering number of ways this can go wrong, and it becomes a REAL pain to maintain, just a complete disaster going into the future. Utter trainwreck. Stay away. Fear. Loathing. Discontent.

    Instead, simply load an entire scene out of Asset Bundle or Addressible. That way when you update the scene and decide to update the downloadable, 100% of everything the scene references just gets automagically sucked into the bundle merely by being used in the scene.

    Once you go scene, you never go back.

    Also, additive scene loading is another possible benefit:

    https://forum.unity.com/threads/right-way-for-performance-divide-scene.1023673/#post-6630961
    https://forum.unity.com/threads/right-way-for-performance-divide-scene.1023673/#post-6754330

    https://forum.unity.com/threads/problem-with-canvas-ui-prefabs.1039075/#post-6726169

    A multi-scene loader thingy:

    https://pastebin.com/Vecczt5Q

    My typical Scene Loader:

    https://gist.github.com/kurtdekker/862da3bc22ee13aff61a7606ece6fdd3

    Other notes on additive scene loading:

    https://forum.unity.com/threads/removing-duplicates-on-load-scene.956568/#post-6233406

    Timing of scene loading:

    https://forum.unity.com/threads/fun...ject-in-the-second-scene.993141/#post-6449718

    Also, if something exists only in one scene, DO NOT MAKE A PREFAB out of it. It's a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.
     
    EdoC-QWERTY likes this.
  9. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    71
    Thank you for this detailed response.

    Yes I was going to use addressables only for level scenes.

    Since you seem to know the subject pretty well I'll ask you some more questions if you don't mind.

    For my first build I used normal scene loading and LoadMode.Single.

    Every thing I needed to was included in every level scene. Besides the level tilemap grid and I have all prefabs for Camera, UI, gameobjects and so on. In this any level can be tested on it's own.

    I have started to make a different build with multiple scenes. There are some scenes that will not be addressables.
    - Main Menu
    - Level selection
    - EndGame scene
    All the other levels will be addressables.


    In the build with multiple scenes it's more difficult to test levels as I have always to start with another scene, and there are also double camera, audiosource problems, as well as other complications like these.

    Do you think t's better that I keep working on the multiple scene build or the single scene build it's gonna work as well?

    Thank you.
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    25,851
    I think multiple scenes are definitely worth chasing. You need to make everything in your game tolerant of perhaps not having stuff ready at the same time, and you have to track things that you need only ONE of:

    - Camera (Main)
    - Audio Listener
    - EventSystem

    I like to put all of those in the BASE scene if possible, then load other scenes like UI and pause and the level itself, etc.

    You have to sort of figure out which works for you. You can actually make Start() be a coroutine too, such as looking to find the player spawn position which might not be ready yet:

    Code (csharp):
    1. private bool ready;
    2.  
    3. IEnumerator Start()
    4. {
    5.   ready = false;
    6.   while( !ready)
    7.   {
    8.     // (however you do the following)
    9.     PlayerSpawn = SearchForPlayerSpawnPoint();
    10.  
    11.     /// if we find it, then we are ready
    12.     if (PlayerSpawn)
    13.     {
    14.      ready = true;
    15.      break;
    16.     }
    17.  
    18.     yield return null;
    19.   }
    20. }
    21.  
    22. void Update()
    23. {
    24.  if (!ready)
    25.  {
    26.    return;
    27.  }
    28.  // do your normal update stuff here...
    29. }
    30.  
     
unityunity