Coding for not seen to start rescan


I was wondering if when Zappar has already recognised a zapcode and is displaying ar if that when the devices camera moves away from the image that you can force Zappar to Rescan for a new zapcode? I am producing a gallery of images that will use ar to overlay extra material. I would like that when the devices camera moves away from one image that it automatically searches for the next zapcode to aid with users with not having to Rescan manually for each item. If anyone can help with this it would be greatly appreciated. I have very little experience with code so a laypersons guide would be much appreciated.


Steven Field


Hey Steven,

This shouldn’t be too hard. I’m assuming you are using Studio and have a target image in your hierarchy and have named it ‘target’.

Add a script to your scene with the following content:

const target =;

target.on("notseen", () => {

Note that this behavior can cause nasty side effects. If the user loses the tracking for even a moment and Zappar detects it, this code will cause the rescanning to start immediately. You could have a buffer timer which requires the target to be not seen for x seconds before the rescanning behavior fires.

Unfortunately I don’t have the time to test this right now, but something along these lines could work:

const target =;
const notseenTimeRequirement = 2000; // 2 seconds

let notseen = false;
let alreadyChecking = false;

target.on("notseen", () => {
    notseen = true;
    if (alreadyChecking == false) {
        alreadyChecking = true;
        Z.after(notseenTimeRequirement, checkNotseen);

target.on("seen" () => {
    notseen = false;

function checkNotseen()
    if (notseen) { Z.device.reset(); }
    alreadyChecking = false;

There’s probably a smarter way to do it, but this is what I came up with for now.

Good luck!


Thanks Slothling,

I utilised the second piece of code that you suggested and it works perfectly for what I need it for.
Once the target is out of view for 2 seconds it starts rescanning.
Thanks for taking the time to help out a novice: It is greatly appreciated. Looking forward to trying to find out what this program can do.




Awesome! Glad I could help. Studio can do a lot once you get into scripting and start to understand how things work under the hood.

Best of luck!