How to block Image Tracking from being activated on certain cons

Hi, I’m using Image Tracking, and the required flow is as such:

Scan Zapcode -> Scan Tracking Image -> Pop up bottle -> Double Tap on Bottle -> Bottle Invisible and disabled, pop out buttons and images -> navigate

The issue that I’m facing is: If I have disabled the bottle from view, once the camera caught the tracking image, it will reenable the bottle into view.

I have tried coding as per below originally as Mix_Recipes.enabled(false) and then changing to !Mix_Recipes.enabled and also !Mix_Recipes.enabled(). All to no luck…

Summary

symbol.nodes.Tracking_Image_pngzpt.on(“seen”, () => {

// Runs when seen occurs on the Tracking Image.png.zpt node

if(!Mix_Recipes.enabled()||!Simple_Swizzles.enabled||XTonicPage.enabled(false)||XTonicPreparation.enabled(false)||XTonicMethod1.enabled(false)||XTonicMethod3.enabled(false)||XTonicDone.enabled(false))

{

symbol.controllers.Visibility.elements.Show.activate();

} else{

symbol.controllers.Visibility.elements.Hide.activate();

}

});

Can anyone suggest where I have gone wrong, or whether it is possible to block image from being tracked under certain conditions?

Hi @vafanarong99,

I’m not sure I 100% understand what you’re trying to achieve here. It sounds like you are overriding the enabled and visible properties each time the target image comes back in view. You could possibly create a boolean variable that hold whether the bottle has been activated and then check when the target image is seen or not seen.

let bottleShown = false;

/*When controller / bottle is shown, change bottleShown to true*/

symbol.nodes.Tracking_Image_pngzpt.on(“seen”, () => {
   if (bottleShown){/*have bottle appear again when target is seen*/}
   
   else{/*bottle stays hidden*/}
)};

Did you know you can also use .one to only run an event once?

Hope this helps.

George