Search Unity

scene resets when i press play

Discussion in 'Editor & General Support' started by ilikecheeseandgaming, Jun 29, 2022.

  1. ilikecheeseandgaming

    ilikecheeseandgaming

    Joined:
    Jun 28, 2022
    Posts:
    3
    i need help my 2nd scene deletes everything in the scene after i go to my 1st scene i think its making a new scene and deleting the one i made but idk what's happening i remade the scene twice and remade all my scripts but nothing works im trying to use scene 2 as level 2 for my platformer game so im trying to open the next scene with this script
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class Finish : MonoBehaviour
    7. {
    8.    private void OnTriggerEnter(Collider other)
    9.    {
    10.         if (other.gameObject.name == "Player")
    11.         {
    12.             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0);
    13.         }
    14.    }
    15. }
    please help me find the problem.
     
    Last edited: Jun 29, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    And how are you "saving the scene?"

    Usually one only keeps the parts one needs, such as score or lives or health or whatever.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - links to documentation you used to cross-check your work (CRITICAL!!!)
    - what actually happened, especially any errors you see

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    You may edit your post above.
     
  3. ilikecheeseandgaming

    ilikecheeseandgaming

    Joined:
    Jun 28, 2022
    Posts:
    3
    im not using a documentation to cross-check my work.