[SOLVED] How to get distance between Nodes?

I have two objects, nodestationary and playerNode.
Both have Node owners in the same position, but with diferent rotations.
Since they are 4 unites away from the node they rotate arround their respectives nodes.
I am trying to determine the distance between they, but :

    float distance = nodestationary.getWorldTranslation().distance( playerNode.getWorldTranslation());

Is not working, its allways getting 4 dosent mather where the objects are in space…
Any way to get the distance here ?

Please paste more code : node attachement and node transformation at least

Sure !

Follow the entire code :

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;

public class Main extends SimpleApplication {

Node centernode = new Node();
Node nodestationary = new Node();
Node playerNode = new Node();

public static void main(String[] args) { new Main().start(); }
public Main() {super(null);}

@Override public void simpleInitApp() {

    // Core Node
    Sphere orbitsphere = new Sphere(32, 32, 0.1f);
    Geometry orbitspheregeom = new Geometry("", orbitsphere);
    Material orbitspheremat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    orbitspheremat.setColor("Color", ColorRGBA.Blue);

    // Stationary box for initial rotation reference
    nodestationary.setLocalTranslation(0, 0, 4.0f);
    Box stationarybox = new Box(0.1f, 0.1f, 0.1f);
    Geometry stationaryboxgeom = new Geometry("Box", stationarybox);
    Material stationaryboxmat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    stationaryboxmat.setColor("Color", ColorRGBA.Red);

    // player Box
    Box playerbox = new Box(0.1f, 0.1f, 0.1f);
    Geometry playerboxgeom = new Geometry("Box", playerbox);
    Material playerboxmat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    playerboxmat.setColor("Color", ColorRGBA.White);
    playerboxgeom.setLocalTranslation(0, 0, 4.0f);

    inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_LEFT));     inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_A ));
    inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_RIGHT));   inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_UP));         inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_DOWN));     inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("space", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addListener(analogListener, "left","right","up","down","space");

private AnalogListener analogListener = new AnalogListener() {
    float speed=0.4f;
    public void onAnalog(String name, float value, float tpf) {
        if (name.equals("up"))    { playerNode.rotate(-speed*5*tpf, 0, 0);  }
        if (name.equals("down"))  { playerNode.rotate(speed*5*tpf, 0, 0); }
        if (name.equals("left"))  { playerNode.rotate(0,(speed*5)*tpf,0); }
        if (name.equals("right")) { playerNode.rotate(0,(-speed*5)*tpf,0); }
        if (name.equals("space")) {}

@Override public void simpleUpdate(float tpf) {

    float distance = nodestationary.getWorldTranslation().distance( playerNode.getWorldTranslation());


In this example, you are setting the nodestationary to (0,0,4) and the playernode stays at (0,0,0)
Your inputs do not change translation but only rotation.
Also you are modifying the playerboxgeom…

I don’t see why the distance between nodestationary and playernode should NOT be 4

Yes, that is exactly my problem.
Their translated distance didnt change, but they may be far from each other after the player rotates it.
There is anyway to determine this distance ?
I expect something between 0 and 8 in this case.
It may not be possible… In this case I may need to determine the rotations diferences…

I am just guessing, but i think what you want is the distance between
nodestationary and the playergeometry
and not
nodestationary and playernode (as you do in your code)

Humm… It works the way you said.
I could not get why, maybe this function dont work with nodes ??

No, the issue is that you are never moving the playernode, so why should the distance change?
But all childs of the node will change the distance relative to the stationary node if you rotate the playernode

Code works as expected and as it should.

Ops. ! My bad ! Its working indeed.
Sometimes I get confused with rotations. I guess I just am afraid of it yet.
Thanks friend !