Billy Putra
Billy Putra

Reputation: 23

Score Didnt show up (Spark AR)

i try write some code to view the score on Spark AR but it not show up on spark editor, and there`s no error on code

whats wrong? can you help me?

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

var SKAWNum = Scene.root.findFirst('test');
var scoreNum = P.outputs.getScalar('score');

SKAWNum.text = scoreNum.toString();

Upvotes: 2

Views: 551

Answers (1)

Martijn Gelton
Martijn Gelton

Reputation: 160

From what I can see you are accessing/getting the patch scalar value incorrectly and the findFirst is used incorrectly.

Your code:

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

var SKAWNum = Scene.root.findFirst('test');
var scoreNum = P.outputs.getScalar('score');

SKAWNum.text = scoreNum.toString();

Here's how you should do it:

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

var SKAWNum = Scene.root.find('test');
var scoreNum = P.getScalarValue('score');

SKAWNum.text = scoreNum.toString();

if the Scene.root.find doesn't work then visit this page which has an example of how you use the findFirst which the find from the code above could also be replaced with.

Upvotes: 1

Related Questions