Hello!
In the following code the first two conditions work properly but I can´t have the final message when both get to the finish line…
namespace MoreMountains.CorgiEngine
{
public class TriggerFinishLine : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnTriggerEnter2D(Collider2D finish)
{ bool metazero = false; // players are not at finish line
bool metaone = false;
if (finish.gameObject == MultiplayerLevelManager.Instance.Players[0].gameObject)
{
Debug.Log("Nico get to the finish line!");
metazero = true; // player 0 get to the finish line
}
if (finish.gameObject == MultiplayerLevelManager.Instance.Players[1].gameObject)
{
Debug.Log("Pablo get to the finish line!");
metaone = true; // player 1 get to the finish line
}
if (metazero == true && metaone == true)// If both players get into the finish line
{
Debug.Log("BOTH get to the finish line");
}
}
}
}
Thank you in advance for your time!!