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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to make game progression similar to Hades?

Discussion in 'Scripting' started by yAcid_Isaac, Sep 18, 2022.

  1. yAcid_Isaac

    yAcid_Isaac

    Joined:
    Mar 11, 2022
    Posts:
    5
    Hello!

    First of all, i'm a beginner at C# but not a programming as a whole, but this may be a little ambicious.
    There's no game yet, i'm just thinking about it, I want to make a 2D game with level progression, but change the starting area a bit every time the player beats one of the levels, as well as unlocking the next level, but I have little to no idea of how to script this, does anyone have any ideas or help in general? Thanks in advance!
     
  2. Zalosath

    Zalosath

    Joined:
    Sep 13, 2014
    Posts:
    671
    Have a list of GameObjects for each level, once the level is completed, activate that list of GameObjects. Could even have another list to store GameObjects you want to deactivate if necessary.
     
    yAcid_Isaac likes this.
  3. me2539901lreplco

    me2539901lreplco

    Joined:
    Nov 11, 2021
    Posts:
    35
    You would simply create multiple scenes, and then use code somewhat like this to switch between scenes.
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6. public class SceneChanger: MonoBehaviour {
    7.     OnCollisionEnter(Collision, col) {
    8.        if (col.GameObject.tag == "Player") {
    9.         SceneManager.LoadScene("Level2");
    10.           }
    11.     }
    12.    
    Then, you would make some sort of way to beat the level. For example if a player collects all coins or gets to a certain point. If you chose the simpler, latter method, you would attach the script above to the 2d object that you want to end the level with. You could do this discretely, with some sort of transparent, small, or camouflaged gameObject, or you could do it more noticeably, with something like a flag pole (mario). Just remember to have a player tagged with player, and name this script SceneChanger. Btw sorry if this has bad syntax or something, but I am relativly new to c# and had this problem a long time ago.
     
    Last edited: Sep 19, 2022
    yAcid_Isaac likes this.
  4. yAcid_Isaac

    yAcid_Isaac

    Joined:
    Mar 11, 2022
    Posts:
    5
    First of all, thanks for the anwers of you guys, just a little question, I was already thinking of doing what you said and your code really helps, but, if I wanted to instead, after the win, transfer the player to a victory screen then to the starting area I would simply do this multiple times right? Seems really straight forward.
    Also, problably the "hardest" part of this would be a game save file, I have somewhat of an idea of how save files work, but at the same time I don't know how/what should I check for the next time the player hits the play button he should be teleported to the last level place he was instead of the first one, maybe it isn't too hard but I could definitely be stuck at that for a while lol, any help about this would be amazing as well.
     
  5. me2539901lreplco

    me2539901lreplco

    Joined:
    Nov 11, 2021
    Posts:
    35
    Oh, all you would have to do is insert
    Code (CSharp):
    1. public int section = 1;
    , and change the value. For a full reference,
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6. public class SceneChanger: MonoBehaviour {
    7.    public int section = 1;
    8.     OnCollisionEnter(Collision, col) {
    9.        if (col.GameObject.tag == "Player") {
    10.         SceneManager.LoadScene("Level2");
    11.         section = 2;
    12.           }
    13.     }
    14.    
    . Then, in your save script, just check the "Section" the player is on, and that will be the level they were on last.
    Also, your reasoning for the victory screen was correct.
     
    Last edited: Sep 19, 2022
    yAcid_Isaac likes this.
  6. yAcid_Isaac

    yAcid_Isaac

    Joined:
    Mar 11, 2022
    Posts:
    5
    Wow, that is actually really simple haha, thanks!
     
    me2539901lreplco likes this.
  7. me2539901lreplco

    me2539901lreplco

    Joined:
    Nov 11, 2021
    Posts:
    35
    You're welcome :) EDIT: Oh.... If you use : ) it corrects that to :)...
     
    yAcid_Isaac likes this.
  8. yAcid_Isaac

    yAcid_Isaac

    Joined:
    Mar 11, 2022
    Posts:
    5
    Hahaha there's also the "Smilies" tab with some cool smilies lol ;) :D :p :cool:
     
    me2539901lreplco likes this.
  9. me2539901lreplco

    me2539901lreplco

    Joined:
    Nov 11, 2021
    Posts:
    35
    Um... I just noticed that the :D is supposed to stand for big grin... I thought that stood for someone pretending to be happy but in reality being nauseated by how disgusting something was lol.
     
    yAcid_Isaac likes this.
  10. yAcid_Isaac

    yAcid_Isaac

    Joined:
    Mar 11, 2022
    Posts:
    5
    The color selection for them probably wasn't the best for some xD :confused:

    But most of them are pretty good, way better than steam ones at least :rolleyes: (there's no way this is a rolling eyes emoji)
     
  11. me2539901lreplco

    me2539901lreplco

    Joined:
    Nov 11, 2021
    Posts:
    35
    yeah ikr
     
    yAcid_Isaac likes this.