Start a new topic

Unity "object trackable" glitch in Unity Inspector

Trying to access the "object trackable" parameters, to get that preview of the point cloud in my Unity scene, but the Inspector window prevents those options from being shown. Are there other was to access that data and to activate the preview?


The glitch happens in both Unity 2019 and 2020.


I attach an image of how it appears:


image



Hi Julian,

Are you getting any errors in the console?

Is the object trackable's inspector showing something if you choose another gameObject in the scene hierarchy and then pick the object trackable again.


Kind regards,
Gökhan

Hi Gökhan


Thanks for getting back to me so quickly. 


Yes, the error seemed to remain, no matter what I did. I also tried different versions of Unity. I was using a Macbook pro. 

I just tried on a PC, and the bug remains. I tried making the "trackable object" manually, by creating an empty game object and adding the script. Then, it seemed normal, until I made the "trackable object" a child of the "object tracker".



This is in the "expert SDK for Unity". 

OK finally got it working. Had to reinstall Unity completely. Now using unity 2019.4 on the Mac.


Another issue:


I can not see the "extended tracking" option. I would like to use the object tracking actually mostly as an "initial placement", and then let Arkit4 handle the world understanding from that point on, as this is a static object (building)

 

Is that possible?


I am currently using the trial version of Wikitude Expert SDK for Unity


image



Alright, I can see now in the documentation that in the Expert edition the "extended tracking" is obsolete, as Arkit world understanding is used instead. That is phenomenal. 


However, where can I find some tutorial or guidelines on how to set this up? 


-Do I make an AR Session / AR Camera and add ARkit scripts 

-How can I use the "on object recognized" / "on object lost" to make sure the object stays in place even if not in view?


Would be great with some pointers on how to set this up, or a link to a tutorial


I can not find any resources on this topic, on how to go about setting up the scene in Unity for this to work. 


Please have a look at my current settings:


I have the AR Bridge set to internal, then added an AR session origin which I also defined in the Wikitude SDK (please also see the results I get in the attached video. I get one cube floating in the air, which is being tracked by ARkit world understanding, and another instance of the cube showing up as object tracked.) 


image


mov

Hi Julian,

You can use either the ARBridge - Multiple Trackers or the ARFoundation - Multiple Trackers scene in the sample scenes.

There, just remove the Image Tracker and you are left with an Object Tracker. 

You can then create a script, which registers to the OnObjectRecognized(ObjectTarget target) and OnObjectLost method of the ObjectTrackable. 

Set an empty gameObject prefab as the drawable for the ObjectTrackable and when the recognition happens, you can instantiate your desired gameObject at the position of target.drawable in the ObjectRecognized method. Parent the desired gameObject to another gameObject though, one which will not be deleted after the object is lost. In an update method, you then can set the position, rotation and scale to the values of the target, but only do this till OnObjectLost is called. After the object is lost, the augmentation still remains in the ARKit-tracked space.


In the scene you set up, everything seems fine already. You can also go from there and use the logic I described above. 


Kind regards,
Gökhan

Hi again


Thanks for that description. I understand the logic there. I am however not a developer with coding experience, but more an artist trying to make this work for an art proposal.


Is there anyway you could provide me with a step by step list of which functions I would go about adding to achieve this? Or provide a very short tutorial? 


image


Hi Julian,


I prepared a little something. Here is how I achieved the desired functionality:

  1. Pick the ARFoundation - Multiple Trackers scene.
  2. Remove the Image Tracker under WikitudeSDK in the scene hierarchy.
  3. Add the script (called ExtendedObjectTracking.cs - code below) to your project.
  4. Add the script as a component to the Controller gameObject in the scene hierarchy.
  5. Define a drawable/augmentation (which you would normally set in the ObjectTrackable).
  6. Remove the drawable in the ObjectTrackable set callbacks to the proper methods of ExtendedObjectTracking in the ObjectTrackable.
  7. Build and run on device and enjoy. This functionality will not work with images though, it will only work with the real(-sized) object.


Kind regards,
Gökhan



using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Wikitude;

public class ExtendedObjectTracking : MonoBehaviour
{
    public GameObject Drawable;
    private GameObject _target;
    private GameObject _drawable;

    private void Start() {
        _drawable = GameObject.Instantiate(Drawable, Vector3.zero, Quaternion.identity, this.transform);
        _drawable.SetActive(false);
    }

    private void Update() {
        if (_target != null) {
            _drawable.transform.position = _target.transform.position;
            _drawable.transform.rotation = _target.transform.rotation;
            _drawable.transform.localScale = _target.transform.localScale;
            if (!_drawable.activeSelf) {
                _drawable.SetActive(true);
            }
        }
    }

    public void OnObjectRecognized(ObjectTarget target) {
        _target = target.Drawable;
    }

    public void OnObjectLost(ObjectTarget target) {
        _target = null;
    }
}


Login or Signup to post a comment