As the title says, I am needing help with two trigger colliders. I am creating a co-operative puzzle game about two cubes, a big cube and a small cube. In this game I am creating a turret that finds and shoots the cube. However, I want the big cube to be detected anywhere around the turret in a circular range (currently working) and the small cube to only be detected in a smaller cube range in front of the turret (not working).
In a sentence, my problem is I am trying to get input from the different triggers separately, and currently just using OnTriggerStay/Enter/Exit only detects the big circle collider (as it is the biggest).
Here is a picture if it helps. Notice the big collider, then the small one.
Thank you if you can help, and sorry if my explanation is a little vague, also I work in C# but java is fine if that is all you know.
I already made some code for detecting the big cube, as seen below, but I need a way to detect them separately. (I have edited it a bit to show you more or less how the small cube should function.)
public Transform target;
public Transform target1;
public GameObject barrel;
public bool inrange;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
}
void OnTriggerEnter(Collider other) {
if (other.tag == "Player1") {
inrange = true;
barrel.particleSystem.Play ();
}
if (other.tag == "Player2") {
inrange = true;
barrel.particleSystem.Play ();
}
}
void OnTriggerStay(Collider other) {
if (other.tag == "Player1") {
transform.LookAt (target);
}
if (other.tag == "Player2") {
transform.LookAt (target);
}
}
void OnTriggerExit(Collider other) {
inrange = false;
}
}