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

avoind loosing "achieved score" when using LoadScene(0) after collision

Discussion in '2D' started by mm_unity870, Apr 12, 2020.

  1. mm_unity870

    mm_unity870

    Joined:
    Feb 7, 2020
    Posts:
    8
    Hi all,

    I developed my first very small game. After a collision the game starts from the beginning. Im am using the statement LoadScene(0).
    When using this the "achieved score/gamepoints" get lost.
    Has anybody an idea how to avoid this? E.g. can I memorize values in a "global" variable?

    Thanks, regards
    Mario
     
  2. Fatcat-Games

    Fatcat-Games

    Joined:
    Nov 9, 2016
    Posts:
    34
    There are many ways to achieve this.The most straight forward way would be to have a public static class with the variable Score. You could also save scores to a text file, or upload them to a web server etc...
     
    mm_unity870 likes this.
  3. mm_unity870

    mm_unity870

    Joined:
    Feb 7, 2020
    Posts:
    8