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
  4. Dismiss Notice

Saving scene for platformer

Discussion in 'Scripting' started by KingTyuio, Oct 9, 2020.

  1. KingTyuio

    KingTyuio

    Joined:
    Jul 8, 2020
    Posts:
    3
    Hello!

    Im here asking how I would save the level the player is on, and when the player were to restart a and hit "Play" It would plop them in the scene they left off in. Thank you, and have a nice day!
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,590
    When loading a level, save its scene index. When starting the game and hitting play, load the last saved index. If you need to save the player position or other information like health as well, do the same for those values (OnApplicationQuit or OnDestroy).
    One way to persist such information between game sessions is PlayerPrefs: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
     
  3. KingTyuio

    KingTyuio

    Joined:
    Jul 8, 2020
    Posts:
    3
    I just need need the level! Have a gread day!