Camera rotation on mouse move

Problem is when user drive a car, user should be able to look around on mouse move. secondly the camera should follow car from decent distance. also I want to drive car with WASD and Up,Down,Right,Left. I mapped input control with WASD and Up,Down,Right,Left. but camera also moving along with it.

Rather than a troubleshooting request, this sounds more like a project specification… please be more specific. :wink:

I am learning JME3 and using Ferrari/Car.scene and town.zip. I am trying to drive car in town scene. right now I am able to drive car but the camera is static and stick to car. see below code.

cam.setFrustumFar(150f);
flyCam.setMoveSpeed(10);
camNode = new CameraNode(“CamNode”, cam);
camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera);
camNode.setLocalTranslation(new Vector3f(0, 6, 20));
Quaternion quat = new Quaternion();
quat.lookAt(new Vector3f(0.0f, 0.0f, -1.0f), Vector3f.UNIT_Y);
camNode.setLocalRotation(quat);
camNode.setEnabled(true);
carNode.attachChild(camNode);

I also have mapped keys

inputManager.addMapping(“Lefts”, new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping(“Rights”, new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping(“Ups”, new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping(“Downs”, new KeyTrigger(KeyInput.KEY_DOWN));

What I am wanting to do is camera should follow car and it should be free to rotate.

In short I want to make car driving like GTA4. GTA IV Gameplay Driving Around - YouTube

You probably need ChaseCamera:

http://wiki.jmonkeyengine.org/doku.php/jme3:beginner:hellochasecam

I tried works nice for following car, but not able to take control of mouse. to rotate camera I have to left click and drag, I want to rotate camera by simply moving mouse. I want to add some other functionality for clicking mouse button.

FlyByCamera.setDragToRotate(false);