C#C
C#3y ago
Raptorini

✅ How to reference gameObject in OnCollisionEnter2D?

public void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "wall_up")
        {
            Debug.Log("Collision detected!");

        }
    }

I don't want to detect collision of the game object the script is tied to, I want to detect collision of an instantiated object called _cell. How do I reference _cell in the collision function?
Was this page helpful?