Search Unity

scene managment not working

Discussion in 'Scripting' started by jadonstudio, Jul 24, 2019.

  1. jadonstudio

    jadonstudio

    Joined:
    Jul 24, 2019
    Posts:
    2
    i'm trying to set something up so that when the player collides with the box it moves to the next level but for some reason the player just goes through the box and nothing happens, i even tried making other things happen when the collision occures like debug.log but still nothing happens.

    heres the code i have ATM. please note that index is replaced with the index number for the scene in the build manager

    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2.  
    3. public class LevelChange : MonoBehaviour
    4. {
    5.  
    6.     public int index;
    7.  
    8. void onTriggerEnter2D(Collider2D other) {
    9.  
    10.         if(other.CompareTag("Player")) {
    11.             SceneManager.LoadScene(index);
    12.         }
    13.     }
    14.  
    15. }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,340
  3. jadonstudio

    jadonstudio

    Joined:
    Jul 24, 2019
    Posts:
    2
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,340
    onTriggerEnter2D must be changed to OnTriggerEnter2D - Capital O. To C# they are as different as naming the method neverActuallyCallThisBecauseWhatever2D and expecting it to work. C# is case sensitive.