"other" does not exist?

EDIT 2: Nevermind. I am an idiot. I was missing “other” in the onTriggerEnter line. I looked right past it like ten times, until a friend pointed it out to me >_>
I’m leaving this here for posterity, in case anyone else makes the same mistake. Save yourself some embarrassment from ole ScaerieTale hahaha

When I enter the code block for other.tags I receive the following error message (full code block below)
CS0103
Description
|The name ‘other’
does not exist in the Assembly-CSharp
current context.

I’ve tried googling it, which just came up with the pseudo-obvious answer of “Other isn’t pointing to anything”, which the error already says. The thing is, in the video, he’s able to just type in if (other.tag == “Package”) as below, and it just works. Not only can I not get VSCode to stop throwing this error, it won’t even try to run the script, so I’m completely stuck.

FWIW I’ve double checked that I created the “Package” tag exactly as shown, and I even went back, removed the script from Player, and completely rewrote it to make sure something wasn’t accidentally removed.

Edit: Sorry, I forgot to add important details :slight_:slight_smile:
OS: Windows 10 Home ver. 21H1
Unity ver: 2021.3240 Personal
Visual Studio Ver: Visual Studio Community 2019 16.11.5

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Delivery : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log(“Beep beep!”);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (other.tag == “Package”)
{
Debug.Log(“Package picked up.”);
}
}
}

1 Like

I’m glad you fixed the problem. And yeah, sometimes, two heads are better than one to spot obvious issues. Typos are very common. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms