1
votes

Im trying to show on console when a gameobject collides with another gameobject with collide. I keep getting this error on unity's console ERROR CS0117, 'Debug' does not contain a definition for 'log'.

  • im on mac using .net core
  • im using vs code 1.35.1 and unity 2019.3.0a5
  • i already have all the usings that i need, but intellisense does not find a definition for my debug or for anything whatsoever, this is frustrating :/
  • i dont have any other .cs file named debug neither

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine.SceneManagement;
    
    public class DeadZone : MonoBehaviour
    {
        private void OnCollisionEnter2D(Collision2D collision){
            Debug.log("Collision");
        }
    
        private void OnTriggerEnter2D(Collider2D collision){
            Debug.log("Trigger");
        }
    }
    

i expect a "collision" message in the console of unity when my ball gameobject touches a wall gameobject, both with collider but i only get that error within the console, i also already tried using UnityEngine.Debug.log(); but havent got any success yet... :(

1
Debug.Log(""); ? - Sergey Anisimov
Method names in C# almost always start with a capital letter. - mjwills
most coding is about attention to detail.. when you're newer at things people dont realise the difference between something and someThing, or SomeThing.. counting of braces and the different types, positioning of variables and methods.. - BugFinder

1 Answers

5
votes

You are using Debug.log(). but you should be using Debug.Log(). Notice the capitalised "L" on "Log".

By naming convention for C# method names will always start with a capital letter.

If you look at the Unity Docs for Debug.Log you'll also see in the code examples/title that it uses the capital L

Also judging from your tags you are using Visual Studio. Make sure that intelliSense is turned on, as this should detect and most of the time even automatically fix these kinds of typos for you.