Doubt with Camera

I'm modifying the example of testsimplephysicsCar jme-bullet is I'm having difficulties to configure the camera as the third person.

my code is this:

                    Camera cam=DisplaySystem.getDisplaySystem().getRenderer().getCamera();
                    Vector3f valor = new Vector3f(0,1,0);
                    float valor2 = physicsCar.getLocalRotation().getY();
                    float raio = 15;
                    float angulo;
                    angulo = (FastMath.PI) * valor2;
       float x = raio * FastMath.cos(angulo);
                    float y = raio * FastMath.sin(angulo);
                    cam.setLocation(new Vector3f(physicsCar.getLocalTranslation().getX()-y,10,physicsCar.getLocalTranslation().getZ()-x));
                    cam.lookAt(physicsCar.getLocalTranslation(),new Vector3f(0,1,0));

when the vehicle rotates 90 degrees the camera is like 45.

Here is a video of this as a Camera:

I noticed that the method getlocalrotation Vehicle class, returns the angle from -1 to 1, and he should 0 = 0


I'm using exactly the following method physicsCar.getLocalRotation (). getY () which returns me a float.

About ChaseCam, I did not get success in implementing it in my code. If I can find a good example, perhaps, enter it.

jmetest.renderer.TestShadowPass uses the ChaseCamera, which is simple enough to use when you know how  :smiley:

private ChaseCamera chaser;

protected void simpleInitGame() {

But I'm using as an example of the code where uses gamestate, I do not know how to implement such enforcement with this method, so I tried to make one manually.

public static void main(String[] args) throws Exception {
       // Enable statistics gathering
       System.setProperty("jme.stats", "set");
            StandardGame game = new StandardGame("A Simple Test");
            if (GameSettingsPanel.prompt(game.getSettings())) {
                                                                    GameTaskQueueManager.getManager().update(new Callable<Void>() {
                                                                       public Void call() throws Exception {
               return null;

TestSimplePhysicsCar just uses an anonymous DebugGameState, so simply insert the code where necessary.

just below the line with

private boolean isSetup=false;

private ChaseCamera chaser;

into update method add...


add in between the anonymous class definition braces ...

private void setupChaseCamera() {
        Vector3f targetOffset = new Vector3f();
        targetOffset.y = ((BoundingBox) physicsCar .getWorldBound()).yExtent * 1.5f;
        chaser = new ChaseCamera(cam, m_character);

...and finally insert into the setupInputHandler inside the IF block:


thanks I will implement the code, and then post the result.


There was no error in the execution, but the Camera does not get behind the vehicle.


My previous problem was not knowing how to configure the camera, I adjusted it, it worked. You can see in the videos below that the result was very good. For now and how do I set up for the car not cloak, suspension, speed or gravity?