javascriptspark-ar-studio

How to solve javascript "Unhandled Promise Rejection" and "Property 'p' doesn't exist" errors?


I'm working on a game using spark ar, by following the tutorial from youtube (blinking game tutorial). apparently when I was working there was an error in the script

    const Scene = require('Scene');
    export const Diagnostics = require('Diagnostics');
    const Patches = require("Patches");

    Promise.all([
        Scene.root.findFirst('number'),]).then(onReady);

    function onReady(assets) {
      var counterNumber = assets[0];
      var scoreNumber = p.outputs.getScalar("score");

      scoreNumber.then(e => {
        e.monitor().subscribe(value => {
          counterNumber.text = value.newValue.toString();
        });
      });
    }

Error : Possible Unhandled Promise Rejection: ReferenceError: Property 'p' doesn't exist


Solution

  • create a const P as below and check whether its working or not

    const Scene = require('Scene');
    const P = require('Patches');
    

    reference taken from Score Didnt show up (Spark AR)