Hello,
I'm trying to set up a thirdpersonview with a chasecamera. Within this view, the user should be able to click on the screen so the playerobject will move to that point.
What i got so far:
I have the object, the cam, the chasecamera, a absolutmouse and everything is fine. Now every time there is a moueclick on screen I'm creating a ray (like in the tuts/other posts in this forum) and I'm detecting the intersection with the terrain. This location should be the worldplace where the user intends to move to.
The strange thing is: This only works for the first time, after the first mouseclick it seems like the position of the camera/display is not updated anymore, because all
mouseclicks result in the same location as the first one.
I got even more irritated when looking at the camera-position of the camera itself, which never seems to change no matter how i rotate or zoom the view. I even only got the correct ray after removing the cam.getLocation()-stuff and start using the translation of the screenCoordinates with z-value 0 and 1…
I thought i got this problem because the chasecamera itself was not updated properly because the object is not moving (i read this in another post), but moving the object by a key-command or a calculated movement to the first correctly selected location makes no difference. :?
I hope that is enough for the moment to describe my problem.
Any idea, suggestion is highly appreciated.
Regards
Sdyx
Ok, now i found the time to post the code:
Here's the code that initialises the cam:
// Assign the mouse to an input handler
HashMap handlerProps = new HashMap();
handlerProps.put(ThirdPersonHandler.PROP_ROTATEONLY, "false");
handlerProps.put(ThirdPersonHandler.PROP_DOGRADUAL, "true");
handlerProps.put(ThirdPersonHandler.PROP_TURNSPEED, "3.1415");
handlerProps.put(ThirdPersonHandler.PROP_LOCKBACKWARDS, "true");
handlerProps.put(ThirdPersonHandler.PROP_STRAFETARGETALIGN, "false");
handlerProps.put(ThirdPersonHandler.PROP_CAMERAALIGNEDMOVE, "true");
handlerProps.put(ThirdPersonHandler.PROP_KEY_FORWARD, ""+KeyInput.KEY_W);
handlerProps.put(ThirdPersonHandler.PROP_KEY_LEFT, ""+KeyInput.KEY_A);
handlerProps.put(ThirdPersonHandler.PROP_KEY_BACKWARD, ""+KeyInput.KEY_S);
handlerProps.put(ThirdPersonHandler.PROP_KEY_RIGHT, ""+KeyInput.KEY_D);
handlerProps.put(ThirdPersonHandler.PROP_KEY_STRAFELEFT, ""+KeyInput.KEY_Q);
handlerProps.put(ThirdPersonHandler.PROP_KEY_STRAFERIGHT, ""+KeyInput.KEY_E);
input = new ThirdPersonHandler(player.getPlayerNode(), cam, handlerProps);
input.setActionSpeed(100f);
HashMap chaserProps = new HashMap();
chaserProps.put(ChaseCamera.PROP_ENABLESPRING, "true");
chaserProps.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(100f, 0f, FastMath.DEG_TO_RAD * 30f));
chaserProps.put(ChaseCamera.PROP_STAYBEHINDTARGET, "false");
chaserProps.put(ChaseCamera.PROP_TARGETOFFSET, new Vector3f(0f, ((BoundingBox) player.getPLayerObj().getWorldBound()).yExtent * 1.5f, 0f));
chaserProps.put(ThirdPersonMouseLook.PROP_ENABLED, "true");
// chaserProps.put(ThirdPersonMouseLook.PROP_MAXASCENT, "" + FastMath.DEG_TO_RAD * 30);
// chaserProps.put(ThirdPersonMouseLook.PROP_MINASCENT, "" + FastMath.DEG_TO_RAD * 0);
chaserProps.put(ThirdPersonMouseLook.PROP_INVERTEDY, "false");
chaserProps.put(ThirdPersonMouseLook.PROP_ROTATETARGET, "false");
chaserProps.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "20.0");
chaserProps.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "240.0");
chaserProps.put(ThirdPersonMouseLook.PROP_MOUSEXMULT, "2.0");
chaserProps.put(ThirdPersonMouseLook.PROP_MOUSEYMULT, "30.0");
chaserProps.put(ThirdPersonMouseLook.PROP_MOUSEROLLMULT, "50.0");
chaserProps.put(ThirdPersonMouseLook.PROP_LOCKASCENT, "false");
chaser = new ChaseCamera(cam, player.getPLayerObj(), chaserProps);
chaser.setActionSpeed(1.0f);
am.registerWithInputHandler(input);
And the update within my Inputhandler:
/**
* This method receives the delegated update
* @param interpolation
*/
public void update(float interpolation) {
cam.update();
input.update(interpolation);
Vector3f cursorLoc =
I found the error, it was the returned list from my heightmanager-class. Seems like trianglepickresult is picking the results just in the order i didn't expect…