Yellow Brackets on debug.log

Hey everyone!, I’m currently working on the 2D course on part 24: If Statements and Tags, However when I get upto the debug.log for the package pick up section, I’m not receiving any logs from the console, also my brackets under the tag seem to be yellow, could anyone offer a solution? Thankyou!

void OnTriggerEnter2D(Collider2D other)

{
    if (other.tag == "Package")
    {
       Debug.Log("Package picked up");
    }
}

Hi,

The colour of the code usually does not matter because it is just a visual help for us programmers. Did you select another colour theme in Visual Studio code? If so, that could explain the yellow curly brackets.

If the if-statement is the only place with yellow curly brackets, check the console of Visual Studio Code. Maybe there is an error message.

Regarding the problem with the tag, log other.tag into your console to see if a) the OnTriggerEnter2D gets executed, and b) what tag the other game object has assigned. Maybe it is not “Package”. The correct spelling is crucial.

Hmm, seems like I forgot some things in my first reply… I’ll send a picture so that you/others can better see my problem


you can see where the logs differ with lines 9 and 16,

Your code looks fine to me. It might be that your colour theme uses different colours for code-blocks of classes and and methods. In my personal opinion, that’s a nice feature because quite a few students accidentally declare methods outside the code-block of the class.

Is something not working?

Privacy & Terms