I’m trying to change a bool value when certain objects (N1,N2 & N3) get clicked on but it is not working. When I click the first object(N1) it DOES change the object color and the variable, as hoped for, but when I get to the second object it does not work anymore. Please check the code to understand:
function OnMouseDown () {
var oneSel = false;
var twoSel = false;
var threeSel = false;
if (gameObject.tag == "N1") {
oneSel=true;
renderer.material.color=Color.red;
Debug.Log(oneSel);
}
if ((gameObject.tag == "N2") && (oneSel==true)) {
twoSel=true;
renderer.material.color=Color.red;
Debug.Log(twoSel);
}
if ((gameObject.tag == "N3") && (twoSel==true)) {
threeSel=true;
renderer.material.color=Color.red;
Debug.Log(threeSel);
}
}
The point is to get the objects clicked in sequence…
What am I doing wrong? Someone please help!