unlike the Topic http://www.jmonkeyengine.com/forum/index.php?topic=12466.0 I want to move the Object to the position like its walking there. So it shall not be set there immediately.
Is there a way to do this like : Objekt.move (location,speed) ?
Or do I need to programm this by myself? If i need to do this by myself, how should I do it?
Thanks for Help.
Okay I got something
Vector3f loc = new Vector3f();
Vector2f screenPos = new Vector2f();
Vector3f worldCoords = display.getWorldCoordinates(screenPos, 0);
Vector3f worldCoords2 = display.getWorldCoordinates(screenPos, 1);
Ray mouseRay = new Ray(worldCoords, worldCoords2.subtractLocal(worldCoords).normalizeLocal());
Vector3f vertex = new Vector3f;
boolean foundMeshHit = false;
if (pr.getNumber() > 0)
TriMesh mesh = (TriMesh) pr.getPickData(0).getTargetMesh();
for (int j = 0; j < mesh.getTriangleCount(); j++)
foundMeshHit = (mouseRay.intersectWhere(vertex.addLocal(mesh.getWorldTranslation()), vertex
.addLocal(mesh.getWorldTranslation()), vertex.addLocal(mesh.getWorldTranslation()), loc));
loc.y = terrain.getHeight(player.getLocalTranslation())
+ ((BoundingBox) player.getWorldBound()).yExtent;
Vector3f pos = player.getLocalTranslation();
Vector3f velocity = loc.mult(tpf);
pos = pos.add(velocity);
pr is an instance of TrianglePickResults. This code is handled in the update method. Unfortunately the location of my mousepick seem not to be correct. It doesnt matter where I'm clicking, the object will not move to the clicked location. Instead its moving straight away and will not be seen anymore. player is a Node, not the Spatial itself. But I think this is not the problem.
My terain which I click on is an instance of TerrainPage. Could this be a problem?
Thanks for the Help.
I found a thread which worke fine for me.
He got a problem when the move order is issued too often. But, as I sayed, it worked fine for me.
I also wanted to know how to do this for a strategy game. I can’t find the TrianglePickResults, is this in JME3?