Nitesh
Nitesh

Reputation: 131

Keep 3D object on screen even after Image target lost in VUFORIA and UNITY

I am creating AR app in which I have 10 Image targets( only 1 recognition at one time). I want to keep the 3D object to be retained even after Target image is lost and update the 3D model after it again found image target (same / or different target)...

I have done so many things like parent change,coroutine, Invoke but none seems to work..

Thanks in advance!

Upvotes: 0

Views: 6236

Answers (4)

Eduardo
Eduardo

Reputation: 1

Check if you don´t have enable the option "Track Device Pose" in Vuforia Engine Configuration in ARCamera object, this option cause object keep in screen.

Disable "Track Device Pose" and this resolve the issue.

Unity 2018.3.6 With Vuforia 7

Upvotes: 0

veerpal kaur
veerpal kaur

Reputation: 1

You can take the position and orientation of the detected object when Vuforia Target is there and then you can Instantiate the same object as:

GameObject generatedObj = Instantiate(mTrackableBehaviour.gameObject, new  Vector3(0,-4.0f,18), Quaternion.identity);
generatedObj.transform.localScale = new Vector3(1,1,1); // change its local scale in x y z format
generatedObj.AddComponent<Translate>();

After doing so disable the ImageTarget from scene and enable again when you want it to be depedent on Marker. But this has the limitation that World co-ordinate experience will not be experienced,it will be like https://www.youtube.com/watch?v=iHhMCdh3k7U

Upvotes: 0

Amit Sharma
Amit Sharma

Reputation: 645

Just enable Extended Tracking from Inspector menu . For Example : enter image description here

Upvotes: 0

Everts
Everts

Reputation: 10721

You can prevent the object from disappearing when target is lost. Simply change the DefaultTrackableEventHandler in the (EDIT) OnTrackingLost method to do nothing.

That will result in your model hanging in the middle of the screen if you lose it fast enough. Of you move away from the target slowly, model gets to the edge and it may be that the tracking gets lost while out of screen.

EDIT:

void OnTrackingFound(){
   TrackerObject[] trackers = FindObjectsOfType<TrackerObject>()
   foreach(var t in trackers){ t.SetOff();}
   this.gameObject.GetComponent<TrackerObject>().SetOn();
}

then you have this TrackerObject component that is attached to all ImageTarget. It has SetOn/Off methods to do what it says.

You can make the code better with storing the info instead of looking for them each time.

Upvotes: 0

Related Questions