I have the following code. What it is supposed to do is print the identifier of each collider, and if the Array that contains the colliders of the 2 last seconds equals to a predefined combo array, print something else. It doesn’t work. It prints EACH collider as expected, but never the combo. Here is my code.
var COMBO:Array;
static var MoveLeftHandCombo:Array=["A","B"];
static var MoveRightHandCombo:Array=["C","D"];
public var startime:float=0;
public var endtime:float=2;
private var thistime:float=0;
function Awake()
{
thistime=startime;
GEST_A=GameObject.Find("GEST_A");
GEST_B=GameObject.Find("GEST_B");
GEST_C=GameObject.Find("GEST_C");
GEST_D=GameObject.Find("GEST_D");
function Update()
{
if (thistime<endtime)
{
thistime+=Time.deltaTime;
}
else
{
COMBO=[];
}
if (COMBO==MoveLeftHandCombo)
{
Debug.Log("MoveLeftHandCombo");
}
else if (COMBO==MoveRightHandCombo)
{
Debug.Log("MoveRightHandCombo");
}
}
function OnTriggerEnter(coll:Collider)
{
if (coll.gameObject==GEST_A)
{
COMBO.push("A");
Debug.Log(COMBO);
}
if (coll.gameObject==GEST_B)
{
COMBO.push("B");
Debug.Log(COMBO);
}
if (coll.gameObject==GEST_C)
{
COMBO.push("C");
Debug.Log(COMBO);
}
if (coll.gameObject==GEST_D)
{
COMBO.push("D");
Debug.Log(COMBO);
}
}