C
C#13mo ago
Ugalde

❔ How to make it so a panel can't appear when another one is active

For a little context, all of the cubes are duplicates with the same tag "Player", except for the assigned to the player which has the tag "RealPlayer" (tag assigned through script), this is so when you cross the finish line it can display a different panel for whether you win or lose. How do I make it so once the win panel is active, the lose panel can´t appear anymore and vice versa?
3 Replies
Ugalde
UgaldeOP13mo ago
This is the script for the finish line:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FinishLine : MonoBehaviour
{
public GameObject winPanel;
public GameObject losePanel;


private void OnTriggerEnter(Collider Col)
{
if (Col.gameObject.tag == "RealPlayer")
{
winPanel.SetActive(true);

}

if (Col.gameObject.tag == "Player")
{
losePanel.SetActive(true);

}
}

// Update is called once per frame
void Update()
{

}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FinishLine : MonoBehaviour
{
public GameObject winPanel;
public GameObject losePanel;


private void OnTriggerEnter(Collider Col)
{
if (Col.gameObject.tag == "RealPlayer")
{
winPanel.SetActive(true);

}

if (Col.gameObject.tag == "Player")
{
losePanel.SetActive(true);

}
}

// Update is called once per frame
void Update()
{

}
}
Buddy
Buddy13mo ago
First thing, please use Col.CompareTag("Player") instead of gameObject.tag == "Player"
How do I make it so once the win panel is active, the lose panel can´t appear anymore and vice versa?
Just have a state which panel is active check whether the other panel is active, then just immediately return.
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server