void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == “Player”)
{
Debug.Log(“player is in room!”);
if (isActive == false)
{
activeRooms.Add(gameObject);
isActive = true;
Debug.Log("Added room to active room!");
}
mapGen.spawn();
}
}
Hey there, I need some help with this code. I’m still learning Unity, so please don’t mind the crappy code. In this sample code, I add the game object this script to list that I made from another script. The isActive variable is used to detect if this game object is already in the list. However, Unity seems to ignore that and lot of this code too? When I play this script, the first Debug.Log is displayed in the console, the game object is added to the list, but nothing else here changes. It doesn’t call the function or change isActive to true. I don’t understand, is it something to do with how triggers or lists work or is it just my code? Thanks.