Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
SparkAR pinLastValue() returning 0;

I'm started a project in SparkAR and having some trouble with getting the correct value in my script in 2 places now. Using .pinLastValue() doesn't provided the number shown in the diagnostics.

Example 1:

const directionX = Reactive.sub(Object.worldTransform.x, Target.worldTransform.x);
const directionY = Reactive.sub(Object.worldTransform.y, Target.worldTransform.y);
const directionZ = Reactive.sub(Object.worldTransform.z, Target.worldTransform.z);

Diagnostics.watch('directionX: ', directionX);
Diagnostics.watch('directionZ: ', directionZ);

Provides the values in the diagnostics:

directionX: -0.44

directionZ: -0.02

const angleRad = Math.atan2(directionX, directionZ);
Diagnostics.watch('angleRad: ', angleRad);

returns null/underfined

const angleRad = Math.atan2(directionX.pinLastValue(), directionZ.pinLastValue());
Diagnostics.watch('angleRad: ', angleRad);

returns angleRad of 0

const angleRad = Math.atan2(-0.44, -0.02);
Diagnostics.watch('angleRad: ', angleRad);

returns the correct value

Example 2:

when I call

const closestIndex = indexes.reduce((acc, cur) => Reactive.max(acc, cur));
Diagnostics.watch('Result',closestIndex);

returns closestIndex as 2

If I try to use closetIndex to find an object by name in my array it doesn't give me the 3rd object [2] in the list it just provides me the first [0]

I'm using:

Diagnostics.log(objArray[closestIndex.pinLastValue()].name);

returns object_0

where I want it to return object_2

In both these examples it doesn't return the number I want (what's in the diagnostics) but just returns 0. What am I doing wrong? Thank you for your time.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!