[SOLVED] getLocalPosition() returns {NaN, NaN, NaN} after tween

Found some odd behaviour in Playcanvas 1.51.7

Finally managed to track down what’s going wrong in my game

This code that used to work fine, about a week ago, and (of course) I haven’t made any changes to it.

I’ve provided a simplified code and output example below.

Any thoughts? @yaustar

//----------------------------------------------
// Sample code, would be attached to an entity
//----------------------------------------------

ScoreChase.prototype.initialize = function() {
 this.heightIndicator = this.entity;
];

ScoreChase.prototype.show = function() {
   let linePos = this.heightIndicator.getLocalPosition().clone();

    linePos.y = linePos.y - 2.0;

    console.log("(BEFORE) getLocalPosition = ", this.heightIndicator.getLocalPosition());

    let self = this;
    this.positionTween = this.heightIndicator
        .tween(this.heightIndicator.getLocalPosition())
        .to({x: linePos.x, y: linePos.y, z: linePos.z}, 0.25, pc.QuadraticInOut)
        .on('complete', function () {
            console.log("HeightIndicator.prototype.setPosition: self.heightIndicator = ", self.heightIndicator);
            console.log("(AFTER) getLocalPosition = ", self.heightIndicator.getLocalPosition());
        });
};


//----------------------------------------------
// Console output
//----------------------------------------------
[Log] (BEFORE) getLocalPosition =  – t {x: 557, y: -12.5, z: 0, …}
[Log] HeightIndicator.prototype.setPosition: self.heightIndicator =  – e {_callbacks: Object, _callbackActive: {}, name: "HeightIndicator", …}
[Log] (AFTER) getLocalPosition =  – t {x: NaN, y: NaN, z: NaN, …}

SOLVED:

Updated to the latest tween.js from the Git repo, and NaN bug is fixed.

Perhaps old version not compatible with some engine releases?

Either way, I am back in business :+1:

Odd. We haven’t changed tween.js nor the engine for a couple of weeks (or at least any changes that would affect this) :thinking:

My tween.js would have been over a year old, as this project has been around for awhile.

Not sure why it would have started failing recently, as this game is in production and working fine.

:thinking: x 2

Ah, the JOY of technology :roll_eyes: :rofl: