"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

Custom Trackable Event Handler

Hello, I am using Unity 2018.3.5 to develop for the HoloLens and I am using Image Targets so show some Objects to the user.

Since I need to add custom behaviour to the detection-progress, I created my own TrackableEventHandler-Script as a copy of the DefaultTrackableEventHandler-Script (as suggested in this post: https://developer.vuforia.com/forum/hololens/modify-ontrackingfound-ontrackinglost-behaviours?sort=2)

The only thing I added to the Handler is a check at the beginning of the OnTrackableStateChanged-Method if the current user position is close enough to a certain, static position. This calculation works, I logged it and the results are correct. The OnTrackableStateChanged-Method should return if the user is not close enough. But when I deploy to the HoloLens, it does not work.

All Objects, which are children of my Image Targets, are shown before I found a target and when I find a target they are placed, regardless if the position check returns true. 

I removed the default component in the inspector of the target-object and added my custom handler, but it still does not work!

Please help me find my mistake!

pmessenger

Mon, 04/01/2019 - 11:48

It sounds like you'd be better off checking per frame if the distance between target and camera are below the threshold, provided the target is being tracked (!).

Thank you, that fixed my problem. It looks like it works as I wanted it too! :)

But I'm a bit unsure about your remark: [quote]a distance check will give you a valid value, just not one you're expecting, most likely[/quote] What do you mean by that?

 

Ginanjar1

Tue, 10/18/2022 - 12:01

Hi, I'm using Unity 2021.3.4fl, why when I create a custom script with a trackable event handler it gets an error after I save it and enter it into Unity. Please help

Hey there,

 

Without the error log no-one will be able to answer your question.

 

Kind regards,

Patrick Scheper

Vuforia Engine Product Manager