Nodes .distance giving funny results

Hi i have problem with using a method .distnace soo i wantes to ask what am i missin.
I have if( node1.get worldtranslation.distnace(node2.getworldtranslation > 5) {
do stupid stuff
and the problem is its not working from all directions,but just from some direction,like if node1 is at a back of node2
then its fine,and it do some stuff ,but if its in front,its not fine at all and it do not do any stuff. Is .distance depends on X+ or X - ,or am i missing some thing alse ?

It will be hard to help unless you show us the real code instead of the hand-mangled-won’t-even-compile code you hand-jammed here.

Who knows how many mistakes you left out?

distance will work as expected when used correctly. So the problem is in the code we can’t see.

1 Like
                       if (enemyClosestStuck !=null){

                  System.out.println(" enemyClosestStuck!=null ");

You need to do some standard debugging… I think your logic is more clever than you are and you are guessing at the wrong issue.

Put some System.out.println()s in there or step through with a debugger. I guarantee you that distance() is returning sensible values and it’s what you are doing with them that is in error.