- Sort Posts
- 22 replies
- Last post
Re: adding multiple trackables in unity
Re: adding multiple trackables in unity
Re: adding multiple trackables in unity
Dear Mr.David
i have created datasets for all 30 trackables, but the problem that im facing right now is that when i use the dataset in ARCamera, i have activated one dataset for a single imagetarget and checked the load dataset checkbox option in the inspector view of the ARCamera, now only that imagetarget is shown whose dataset i have activated, while the other imagetargets do not show when i move the camera towards their respective trackables :/
please help
Re: adding multiple trackables in unity
adding multiple trackables in unity
Sorry to bump such an old thread guys....
im a noob and i want to create a scene that has 10 trackables stored in it,
when the camera 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.
Also i dont have unity pro, any ideas of how i could elegantly get a pre loader every time it spots a tracker that isnt the one loading?
As far as im aware pre loaders are for unity pro only.
adding multiple trackables in unity
What you'll need to do, is to generate a dataset from the TMS that contains all 10 trackables. You'll need to add this to the ARCamera of every scene that you're authoring. You'll also need to add each target to every scene, so that they are detectable and you can go from a given scene to any other.
To switch between scenes, add your scene navigation logic to the DefaultTrackableEventHandler's OnTrackingFound method. I'd recommend doing this in C#, otherwise you'll need to call a JS component.
adding multiple trackables in unity
Hi David, thanks for getting back to me....
I have the scene set up and have opened the c# file named: DefaultTrackableEventHandler's
I have changed the function as suggested to:
private void OnTrackingFound()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
// Enable rendering:
foreach (Renderer component in rendererComponents) {
component.enabled = true;
}
if (mTrackableBehaviour.TrackableName == "01_Trackable"){
Debug.Log("Trackable 01 found");
//Application.LoadLevel ("Level_01");
}
if (mTrackableBehaviour.TrackableName == "02_Trackable"){
Debug.Log("Trackable 02 found");
//Application.LoadLevel ("Level_02");
}
if (mTrackableBehaviour.TrackableName == "03_Trackable"){
Debug.Log("Trackable 03 found");
//Application.LoadLevel ("Level_03");
}
if (mTrackableBehaviour.TrackableName == "04_Trackable"){
Debug.Log("Trackable 04 found");
//Application.LoadLevel ("Level_04");
}
if (mTrackableBehaviour.TrackableName == "05_Trackable"){
Debug.Log("Trackable 05 found");
//Application.LoadLevel ("Level_05");
}
if (mTrackableBehaviour.TrackableName == "06_Trackable"){
Debug.Log("Trackable 06 found");
//Application.LoadLevel ("Level_06");
}
if (mTrackableBehaviour.TrackableName == "07_Trackable"){
Debug.Log("Trackable 07 found");
//Application.LoadLevel ("Level_07");
}
if (mTrackableBehaviour.TrackableName == "08_Trackable"){
Debug.Log("Trackable 08 found");
//Application.LoadLevel ("Level_08");
}
if (mTrackableBehaviour.TrackableName == "09_Trackable"){
Debug.Log("Trackable 09 found");
//Application.LoadLevel ("Level_09");
}
if (mTrackableBehaviour.TrackableName == "10_Trackable"){
Debug.Log("Trackable 10 found");
//Application.LoadLevel ("Level_10");
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
}
Ive commented out the code as im in debug, but when i pley play and move the camera around over the variuos trackables it does register.
The console spits out errors:
Trackable 02_Trackable found
UnityEngine.Debug:Log(Object)
DefaultTrackableEventHandler:OnTrackingFound() (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:113)
DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status) (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:49)
TrackableBehaviour:OnTrackerUpdate(Status) (at Assets/Qualcomm Augmented Reality/Scripts/TrackableBehaviour.cs:150)
QCARManager:UpdateTrackablesEditor() (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:421)
QCARManager:UpdateTrackers() (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:329)
QCARManager:Update(ScreenOrientation) (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:223)
QCARBehaviour:Update() (at Assets/Qualcomm Augmented Reality/Scripts/QCARBehaviour.cs:274)
Ive PM'd you the test project for your perusal.
If you could help me out id be eternally grateful!
adding multiple trackables in unity
its hammering the memory,
im gettin 1 frame every 2 seconds, it would appear to be constantly loading the same scene again and again,
It loads the first tracker, then a scan across to the next and it locks up, like its caught in a loop.
Is there a way to detect if different maybe? Its almost as if its constantly reloading.
#
thx man
adding multiple trackables in unity
Ok, is 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<Renderer>();
// 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");
}
adding multiple trackables in unity
I've had a chance to look at your project, and it is working. The Unity player will pause when loading new scenes, which may be what you're seeing. See my PM for instructions on how to reduce this effect.
LoadLevelAsync |
Loads the level asynchronously in the background. |
LoadLevelAdditiveAsync |
Loads the level additively and asynchronously in the background. |
LoadLevelAdditive |
What devices are you seeing crashes on?
If you want to avoid a scene loading pause entirely, you'll need to design your app as a single scene and handle any sequencing of the targets programmatically.
adding multiple trackables in unity
private void OnTrackingFound()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
// Enable rendering:
foreach (Renderer component in rendererComponents) {
component.enabled = true;
}
if (mTrackableBehaviour.TrackableName == "01_Trackable" && (Application.loadedLevelName != "Level_01")){
//Debug.Log(myGameObject.LevelLoaded1.Level01IsRunning);
//Debug.Log("Trackable 01 found");
Application.LoadLevel ("Level_01");
}
if (mTrackableBehaviour.TrackableName == "02_Trackable" && (Application.loadedLevelName != "Level_02")){
//Debug.Log("Trackable 02 found");
Application.LoadLevel ("Level_02");
}
//Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
}
You'll simply need to create a dataset from within the TMS website that contains these Trackables, and then import this into your project. Then configure the Data Set Load Behaviour on the ARCamera to load and activate this dataset. Each ImageTarget that you use will need to be configured for a given trackable using the Image Target Behaviour panel in the inspector.
Is this what you are asking?