Before this lecture, I made a key for the door which is linked to a public bool “hasKey” which the Level Exit script reads to either display “Key Needed” or advance to the next level. I did this in the player script as follows:
void OnTiggerEnter2D(Collider2D other)
if(other.tag == "Key")
{
hasKey = true;
Destroy(other.gameObject);
}
Why can’t I simply add another bit to the same method saying:
if(other.tag == "Coin")
{
Destroy(other.gameObject);
}
This would prevent the error Rick had where he forgot to add the script to the game object as the player is handling interacting with the rest of the world.