Question by
MrJump · Feb 01, 2018 at 12:58 AM ·
booleantagload scene
Load Scene with 2 GameObjects OnTriggerEnter
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameOver : MonoBehaviour {
void OnTriggerEnter(Collider other) { if ((other.tag == "Ball") || (other.tag == "Ball2")) {
SceneManager.LoadScene("GameOver");
}
} }
I figured out how to Load Scene When I get one of the game objects collide. But I'm trying to load new scene when both game objects entered, any advice would be grateful.
Comment
public int ball1;
public int ball2;
void OnTriggerEnter(Collider other)
{
if ((other.tag == "Ball") {
ball1=1;
}
else if(other.tag == "Ball2"){
ball2=1;
}
if(ball1==1 && ball2==1){
Scene$$anonymous$$anager.LoadScene("GameOver");
}
}
}
}
^_^
Your answer
![](https://koobas.hobune.stream/wayback/20220612151717im_/https://answers.unity.com/themes/thub/images/avi.jpg)