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

Karting Microgame - How do you adjust time limit and first record that i stored?

Discussion in 'Editor & General Support' started by Helle, Jan 4, 2022.

  1. Helle

    Helle

    Joined:
    Aug 4, 2017
    Posts:
    6
    Hi, i was wondering where you can adjust the time limit and the record that is stored as the first data, when you start the karting microgame.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,951
    Since most people here are not interested in doing this tutorial to explain something to you, this piece of research would be a great thing for you to do in Step #2 of how to do a tutorial properly. Read on.

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Tutorials are a GREAT idea. Tutorials should be used this way:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!

    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!
     
  3. Helle

    Helle

    Joined:
    Aug 4, 2017
    Posts:
    6
    Well at least thanks for your long replay. Well the tutorial only tells me how to change the game from record time to record how many laps you do So is there some who knows how to adjust those two numbers?
     
  4. Helle

    Helle

    Joined:
    Aug 4, 2017
    Posts:
    6
    I found 50% of the answer. You just go to MainScene and check the Hierarchy under Objective TimeLimit. There you can add total time in second.
    ( If other run into same problem in the future, you can read it here :) )

    So BASIC KURT WAS CORRECT, YOU NEED DO IT AGAIN LOL
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,951
    Don't you feel smart now!!? It's awesome. Well done Helle. Makes me smile to see you did that.

    Now for the other half, do you mean you want something to store the best time? Or best score? Basically a high score chart?

    There are lots of tutorials for that, but if you just want to cut to the simplest fastest way to do it, here is a way:

    Tracking simple high score / low time single-entry leaderboard:

    For the highest score: https://pastebin.com/VmngEK05

    Usage:

    Code (csharp):
    1. TheBest.RecordScoreIfHigher( lastGamePlayScore);
    For the lowest time: https://pastebin.com/A7GC76uQ

    Usage:

    Code (csharp):
    1. TheBest.RecordTimeIfLower( lastGamePlayTime);
    To retrieve the best score or time, use one of these:

    Code (csharp):
    1. int bestScore = TheBest.BestScore;
    Code (csharp):
    1. float bestTime = TheBest.BestTime;
    Full usage example:

    https://pastebin.com/ygFAvNsM
     
  6. Helle

    Helle

    Joined:
    Aug 4, 2017
    Posts:
    6
    Thanks again, can use that when I start from fresh. But this learning tutorial Karting Microgame have a system build into it.


    Just now i try find where the data is stored when you first start the game. It tell on the screen current time is 23:20 and best lap is 23:20. I can’t find the place yet that those two number are stored.


    It kind of look bad when my track take nearly take1 min to finish, and best lap is already 23 sec.


    I have only used unity for 30 hours, so I am green as you get it lol


    You can see the picture. Well think you need download the karting microgame to help me there.


    Only thing I can promise, if I ever finish this game i should give you some credit for helping me if you find the answer. LOL


    Thanks anyway, at least there was 1 person that tried to help me.
     

    Attached Files:

    • time.png
      time.png
      File size:
      899.5 KB
      Views:
      219
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,951
    One idea: search for all uses of the word PlayerPrefs in the game.

    Another idea: figure out how that best score is updated. One easy way is to DELETE the best time object, run the game and see what code complains and throws errors, then restore it.

    Once you see the code that sets it onscreen, you can figure out where the value comes from and reason about how you could reset it.
     
  8. Helle

    Helle

    Joined:
    Aug 4, 2017
    Posts:
    6
    Well i have mange to work around it, it is a messages screen.
    So this no longer a problem. It is solved .
    It now just shows the time and not the best track time.

    Well thanks for all the input , it was great. This is how far i have come yet, it is not finish :

    Tiny Town Grand Prix

    Helle - Unity Play

    i
     
    Last edited: Jan 24, 2022