[SOLVED] Issue with my > operator

Given the following code, can anyone decipher why I would be getting an issue where the if statement will fire when distanceFromKillPlane is greater than 2 or between 0 and 1? The if statement will fire from 0.0001 - 0.9999

var distanceFromKillPlane = 
this.app.root.findByName("ballForTrack").getWorldTransform().getTranslation().clone().y - 
this.app.root.findByName("shadowCatcher").getWorldTransform().getTranslation().clone().y;
//checks to see how close the ball is to the kill plane
if (distanceFromKillPlane > 2){
        //do something
}

Hi @Jake_Johnson,

Not sure right now, but you don’t have to clone() a vector to get its y element, you can skip that. Also any particular reason why you are getting the translation from the world transform instead of the entity directly?

this.app.root.findByName("ballForTrack").getPosition().y;

No idea but I just realized my initial assertion isn’t true so never mind. I’m going to delete the thread. thanks Leonidas.

1 Like

Wait I have no ability to delete the thread. If anyone on the PlayCanvas staff wants to delete this, go ahead.

1 Like