Parent on seen repeats the experience

Hi forum,

When I scan the Zapcode, my experience starts and my animated character is seen (which is what I want), but if I accidentally “see” the Zapcode again (not by rescanning it - just by losing the tracking), it starts the experience again while the previous experience is happening. This includes 2D and 3D animations, and sound effects.

Here is my code which appears in only one script in the experience:

Blockquote
parent.on(“seen”, () => {
// Runs when seen occurs on the parent node

symbol.controllers.Tessa_anim.elements.Tessa_notseen.activate();
symbol.controllers.Tessa_anim.elements.Tessa_seen.activate();

//02
symbol.nodes.Tessa_sound_1_1_ogg.start();
//symbol.controllers.Tessa_anim.elements.Tessa_anim_01.play();

symbol.controllers.Case_01_Tessa.elements.n02.activate(); });

How can I ensure that if the user loses the tracking marker but comes back to it later that it doesn’t reset everything for them, or it plays the experience over the top of the first? I would want the audio and 2D graphics to continue, and ideally the animation as well.

Thank you in advance!

You can try changing on to one. One is only ran one time.

Steve

Hi @stevesanerd and thanks for your quick reply!

I just tried it and it’s great! It works!

For anyone else looking for the answer, the one function is here.

And I changed my code to this:

parent.one(“seen”, () => {
// Runs only onces when seen occurs on the parent node

2 Likes

Your welcome.
:grin:

Steve