- Home /
How to detect multiple trackables in Vuforia
im a noob and i want to create a scene that has 10 trackables stored in it, when the ARcamera points at one trackable it quickly loads that scene, When it is pointed to another trackable it loads that one instead, So all the 10 scenes are looking for all 10 trackers.
What I did was to generate a dataset from the TMS that contains all 10 trackables. Adding this to the ARCamera of every scene that you're authoring. Adding each target to every scene, so that they are detectable and you can go from a given scene to any other.
The problem is it loads the first scene then it keeps loading it (ithink), as when i finds another tracker it just freeze until i point the device away.
I then edited DefaultTrackableEventHandler.cs (see attachment & below) link text
You will see I tried creating a flag so that it only loads a level if its not found the level its on,
private void OnTrackingFound() { Renderer[] rendererComponents = GetComponentsInChildren();
// Enable rendering:
foreach (Renderer component in rendererComponents) {
component.enabled = true;
}
if (mTrackableBehaviour.TrackableName == "01_Trackable" && LevelLoaded1.Level01IsRunning != 1){ Debug.Log("Trackable 01 found"); Application.LoadLevel ("Level_01");
}
if (mTrackableBehaviour.TrackableName == "02_Trackable" && LevelLoaded2.Level02IsRunning != 1){ Debug.Log("Trackable 02 found"); Application.LoadLevel ("Level_02");
}
if (mTrackableBehaviour.TrackableName == "03_Trackable" && LevelLoaded3.Level03IsRunning != 1){ Debug.Log("Trackable 03 found"); Application.LoadLevel ("Level_03");
}
if (mTrackableBehaviour.TrackableName == "04_Trackable" && LevelLoaded4.Level04IsRunning != 1){ Debug.Log("Trackable 04 found"); Application.LoadLevel ("Level_04");
}
if (mTrackableBehaviour.TrackableName == "05_Trackable" && LevelLoaded5.Level05IsRunning != 1){ Debug.Log("Trackable 05 found"); Application.LoadLevel ("Level_05");
}
if (mTrackableBehaviour.TrackableName == "06_Trackable" && LevelLoaded6.Level06IsRunning != 1){ Debug.Log("Trackable 06 found"); Application.LoadLevel ("Level_06");
}
if (mTrackableBehaviour.TrackableName == "07_Trackable" && LevelLoaded7.Level07IsRunning != 1){ Debug.Log("Trackable 07 found"); //Application.LoadLevel ("Level_07");
}
if (mTrackableBehaviour.TrackableName == "08_Trackable" && LevelLoaded8.Level08IsRunning != 1){
Debug.Log("Trackable 08 found");
//Application.LoadLevel ("Level_08");
}
if (mTrackableBehaviour.TrackableName == "09_Trackable" && LevelLoaded9.Level09IsRunning != 1){ Debug.Log("Trackable 09 found"); //Application.LoadLevel ("Level_09");
}
if (mTrackableBehaviour.TrackableName == "10_Trackable" && LevelLoaded10.Level10IsRunning != 1){ Debug.Log("Trackable 10 found"); //Application.LoadLevel ("Level_10");
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
}
And in each level there is a game object with its own unique JS script attached with the following:
static var Level01IsRunning = 1; static var Level02IsRunning = 0; static var Level03IsRunning = 0; static var Level04IsRunning = 0; static var Level05IsRunning = 0; static var Level06IsRunning = 0; static var Level07IsRunning = 0; static var Level08IsRunning = 0; static var Level09IsRunning = 0; static var Level10IsRunning = 0;
function OnGUI () { GUI.Box (Rect (0,0,200,50), "level1"); }
It builds without error but when i run the APK on my phone and pint to the different trackables its stays on level 1 so the folling type bits are never true:
if (mTrackableBehaviour.TrackableName == "02_Trackable" && LevelLoaded2.Level02IsRunning != 1){
Please help...
Oh ive also moved all my JS scripts into the plugins folder as mentioned on other posts, doesnt seem to help on this occasion.
It now never loads any levelslink text