"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Add numbers when different image targets are detected

Hi, I am new in developing AR applications. I am currently creating a learning app that will perform a specific operation using AR.

Two ImageTargets contain one number each, another ImageTarget that is containing an operation,and an ImageTarget of the equal sign.  

What I like to do is when I aim the camera to the first number it will go to a script that contains an integer container, then when the camera is aimed to the operation it will also be passed on a script, and so as the second number. Once the three is complete, the camera will be aimed towards the equal imagetarget and display the sum/difference/quotient/product. 

What happens to my code is that when I aim the camera to the opeation, it only displays "000" which should be 1+0.

Below is the code that I have used:

using UnityEngine; using System.Collections; using Vuforia;

public class ARNumbers : MonoBehaviour , ITrackableEventHandler{

private TrackableBehaviour mTrackableBehaviour; public int a, b, c, d, counter = 0; public string operationX; void Start() {   mTrackableBehaviour = GetComponent<TrackableBehaviour>();   if (mTrackableBehaviour)   {    mTrackableBehaviour.RegisterTrackableEventHandler(this);   } }

public void OnTrackableStateChanged(   TrackableBehaviour.Status previousStatus,   TrackableBehaviour.Status newStatus) {   if (newStatus == TrackableBehaviour.Status.DETECTED ||    newStatus == TrackableBehaviour.Status.TRACKED ||    newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)   {    if ( gameObject.tag =="1")    {     a = 1;     counter = 1;    }        if ( gameObject.tag =="2")    {     a = 2;     counter = 1;    }

   if (a == 1 && counter == 1 && gameObject.tag =="plus")    {     a = 1;     counter = 2;     operationX = "+";    }

   if (a == 2 && counter == 1 && gameObject.tag =="plus")    {     a = 2;     counter = 2;     operationX = "+";    }

   if (a == 1 && counter == 2 && gameObject.tag == "2")    {     a = 1;     b = 2;     counter = 3;    }

   if (a==2 && counter == 2 && gameObject.tag == "1")    {     a = 2;     b = 1;     counter = 3;    }

   Debug.Log (a+operationX+b+" "+counter);   }   }  

}

I need help. Thanks!