Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Debug Log Error Collision detected

Discussion in '2D' started by pokemontybor, Jun 11, 2019.

  1. pokemontybor

    pokemontybor

    Joined:
    Jun 11, 2019
    Posts:
    8
    Hi, i'm trying to load in my scene but every time I do it pauses it which means I have to un pause it this makes it very difficult to test I don't know if it is because of the Debug Log Error but that is the only error I have found.

    Here is the code:

    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    using UnityEngine.SceneManagement;





    public class AreaExit : MonoBehaviour

    {





    public string areaToLoad;

    public string areaTransitionName;




    // Start is called before the first frame update

    void Start()

    {



    }



    // Update is called once per frame

    void Update()

    {



    }



    private void OnTriggerEnter2D(Collider2D other)


    {

    if(other.tag == "Player")

    Debug.LogError("Collisiondetected,TryingtoLoad");

    {

    SceneManager.LoadScene(areaToLoad);


    }

    }

    }
     
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    use just Debug.Log
     
  3. pokemontybor

    pokemontybor

    Joined:
    Jun 11, 2019
    Posts:
    8
    What do you mean?
     
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    First, please use code tags.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class AreaExit : MonoBehaviour {
    7.    public string areaToLoad;
    8.    public string areaTransitionName;
    9.  
    10.    // Start is called before the first frame update
    11.    void Start() {
    12.  
    13.    }
    14.  
    15.    // Update is called once per frame
    16.    void Update() {
    17.  
    18.    }
    19.  
    20.    private void OnTriggerEnter2D(Collider2D other) {
    21.       if(other.tag == "Player")
    22.          Debug.LogError("Collisiondetected,TryingtoLoad");
    23.  
    24.       {
    25.          SceneManager.LoadScene(areaToLoad);
    26.       }
    27.    }
    28. }
    Your if-statement seems to be incorrect here. The SceneManager.LoadScene line is not part of the condition and will run regardless. You probably meant to do this:
    Code (CSharp):
    1. private void OnTriggerEnter2D(Collider2D other) {
    2.    if(other.tag == "Player") {
    3.       Debug.LogError("Collisiondetected,TryingtoLoad");
    4.       SceneManager.LoadScene(areaToLoad);
    5.    }
    6. }
     
  5. pokemontybor

    pokemontybor

    Joined:
    Jun 11, 2019
    Posts:
    8
    It is still pausing when I come out
    It is still pausing the game when I come out
     
  6. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    I'm not sure what you mean by this.
     
  7. pokemontybor

    pokemontybor

    Joined:
    Jun 11, 2019
    Posts:
    8
    When I go in and out of the scene my game pauses I am trying to find a solution
     
  8. pokemontybor

    pokemontybor

    Joined:
    Jun 11, 2019
    Posts:
    8
    I am sorry if I am bugging you but I want to finish my game soon
     
  9. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    I mean use Debug.Log instead of Debug.LogError if you believe the error is freezing