Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C# Unity not displaying Debug.Log() console

I am writing a script that shows a collision between one object and an obstacle. The code runs but does not output within the console. Is there something that I am doing wrong?

using UnityEngine;

public class collision : MonoBehaviour{

    void OnConllisionEnter (Collision collisionInfo)
    {
        if(collisionInfo.collider.tag == "Obstacle") 
        { 
            Debug.Log("We Hit an obstacle!");
        }
    }
    
}

I added a tag to the object as I will be adding more obstacles to simplify the process. I checked for semicolons and any other errors that would stand out to me. I am not sure what I am supposed to change or if I am missing something.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You actually have a typo in the methods name

//       Here
//        |
//        v
void OnConllisionEnter (Collision collisionInfo)

The code should be

using UnityEngine;

public class collision : MonoBehaviour{

    void OnCollisionEnter (Collision collisionInfo)
    {
        if(collisionInfo.collider.tag == "Obstacle") 
        { 
            Debug.Log("We Hit an obstacle!");
        }
    }
    
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading