Hey,
So I’ve finished the ‘Roll a Ball’ tutorial and I’m trying to implement two new cubes: ‘Bonus Cube’ and ‘Bad Cube’.
Basically, I want the ‘Bad Cube’ to Deactivate the Player Ball (And the Cube) and display a message along the lines of “You Lose”, and the ‘Bonus Cube’ to just display a message under the ball count saying something along the lines of ‘Bonus Cube Collected!’
I’ve set up the new cubes as prefabs, and all the text etc works when I interact with the basic ‘Pick Up’ cube as a test, but my issue lies with the OnTriggerEnter(Collider other) function.
I’ve made a kind of pseudo-addition to the original code to show you what I’m trying to accomplish (Right now rolling into the Bad Cube/Bonus Cube does nothing, you just phase through it)
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Pick Up")) { //If the tag is the same as the string value...
other.gameObject.SetActive (false); //... The game object will be deactivated.
count = count + 1; //This changes out current value of count by +1.
SetCountText (); //This calls the SetCountText function.
if (other.gameObject.CompareTag ("Player")) {
other.gameObject.SetActive (false);
loseText.text = "YOU DIED";
}
if (other.gameObject.CompareTag ("Bonus Cube")) {
other.gameObject.SetActive (false);
bonusText.text = "Bonus Cube Collected!";
}
}
Any help will be appreciated! Cheers.