Im trying to make the (floor1 change to the floor2) and the (floor2 change to the floor1) when the player object enter in their colliders. The problem is obviously that i am triggering the two triggers at the almost same time, and the floors keep changing unless i step out of them. I want to keep the floors triggering once per time, whithout using OnTriggerExit2D, must be OnTriggerEnter2D.
Im using the following code to the floors:
public class changeFloor_AtoB : MonoBehaviour
{
public GameObject fa;
public GameObject fb;
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
fa.SetActive(false);
fb.SetActive(true);
}
}
}
public class changeFloor_BtoA : MonoBehaviour
{
public GameObject fa;
public GameObject fb;
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
fa.SetActive(true);
fb.SetActive(false);
}
}
}