Hello! I’m working on a simple Application. I want to have 2 overlapping buttons, one of which will add a point to your score, and the other one will bring you to the next scene(Game Over Screen). I already have the coding for the point system and the scene switch. I want these buttons to alternate being Enabled and Disabled based off of a continuously rotating object’s collision with a trigger at the top of its path(GreenZone). So if the rotating object is inside the GreenZone, (Enable pointButton, Disable loseButton) and if it’s outside, (Disable pointButton, Enable loseButton). That’s the only issue I’m having getting this done and I’m at a complete loss on what to do. I want to know if this is the best way to do something like this, and if so, how! Thanks, guys<3
If I understand correctly, you should add a collider to a gameObject that covers the green zone area. You should then set that collider to be a trigger. Triggers only work if one of the colliding gameobjects have a rigidbody component attached to them. So add it if you don’t have one. Then in a script attached to the gameObject that has that collider trigger, add something like;
void OnTriggerEnter(Collider col){
// object is in the green zone, set the buttons (for example...)
GameObject.Find("PointsButton").GetComponent<Button>().interactable=false;
GameObject.Find("GameOverButton").GetComponent<Button>().interactable=true;
}
void OnTriggerExit(Collider col){
// object has left the green zone, set the buttons (for example...)
GameObject.Find("PointsButton").GetComponent<Button>().interactable=true;
GameObject.Find("GameOverButton").GetComponent<Button>().interactable=false;
}