Hi! I have a script, that makes an object float up and down. This whole math magic is running inside the update(dt) function. The code is pretty simple.
However it contains a start and end lerp to actually float up to a proper value, then float down when turning it off. To do this, I save the original position of the entity on the start, and compare the current position to this. So the update function (stripped down) looks like this:
Float.prototype.update = function(dt) {
if(weShouldFloat_Bool){
// Calculate and modify position here.
} else {
// If we should not float, lerp back to start here
console.log("GetLocalPos():" + this.entity.getLocalPosition() + " and OriginalPos: " + originalPos + " are not equal.");
if(!this.entity.getLocalPosition().equals(originalPos)){
console.log("Running inside getLocalPosition().equals(originalPos) loop");
}
}
};
Both of the values are printed as [0, -0.1, 0]
yet the If runs as if they were not equal, as seen on these images below. I have tried getLocalPosition != originalPos
as well as the getLocalPosition().equals(originalPos)
as you can see in the code snippet above.
Sooo… what is exactly happening here?
EDIT:
Tried Vector1 !== Vector2
as well. Both of them are initialized as new pc.Vec3();