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

Roll a Ball Based Game Project.

Discussion in 'Scripting' started by Snake1188, Aug 6, 2015.

  1. Snake1188

    Snake1188

    Joined:
    Aug 6, 2015
    Posts:
    2
    Hello Everyone!

    I'm working about a month on a project, wich i started out from the Roll a Ball Tutorial, here from unity! :D

    but now i'm facing a problem...

    i want the player to need different Scores on every level, for example...

    Level 1 = 10 Points to Pass.
    Level 2 = 20 Points to Pass.
    and so on...

    but i can only define the Value as a fixed number... for example, if i put "100" the player will need 100 points even in Stage 1.
    if someone can help, please do ! :)
    here is the code, almost all provided from the Roll a Ball video Tutorial.

    Code (CSharp):
    1. void SetCountText ()
    2.     {
    3.         countText.text = "Count: " + count.ToString ();
    4.         if (count >= 100)
    5.         {
    6.             int i = Application.loadedLevel;
    7.             Application.LoadLevel(i + 1);
    8.             winText.text = "You Win!";
    9.         }
    10.     }
     
  2. Arcatus

    Arcatus

    Joined:
    May 27, 2015
    Posts:
    45
    Ah, the rollerball. Great tutorial.

    I am using still using assets from the spaceshooter tutorial as placeholder art in my project :)

    Something like

    Code (CSharp):
    1.  
    2. void SetCountText ()
    3. int i = Application.loadedLevel;  //initiating the variable here so the "if" can use it.
    4.      {
    5.         countText.text = "Count: " + count.ToString ();
    6.         if (count >= i*10)
    7.         {
    8.             Application.LoadLevel(i + 1);
    9.             winText.text = "You Win!";
    10.         }
    11.     }
    This isn't perfect, the "You Win!" text will not display, as you destroy all objects as you load the new scene. (unless this object, and the text object is set to "don't destroy on load"
     
  3. supamigit

    supamigit

    Joined:
    Dec 2, 2012
    Posts:
    22
    Why havent you tried using enable and disable on UNITY 4.6 CANVAS or what it now Set.Active() etc... so much easier and seems to follow across scenes nicely too...