[Newbie] Camera Rotate Performance Glitch?

Hello there.

Im tryng to make a normal camera, focusing its view on a physical object. The camera moves as the physical object moves. The physical object moves changes directions as camera rotates, with this :

[java]if (IO.left) {


} else

if (IO.right) {



Now, the ‘glitch’ ive seen is, whenever i rotate the camera when im moving the character, it gets glitchy and it seems it doesnt render right, gets a little laggy, or the object a little bit out of center.

The tricky part is: the camera has aceleration for rotation.

This is my camera class code:


  • To change this template, choose Tools | Templates
  • and open the template in the editor.


    package theDungeon;

    import com.jme3.input.ChaseCamera;

    import com.jme3.math.FastMath;

    import com.jme3.math.Vector3f;

    import com.jme3.renderer.Camera;

    import com.jme3.scene.CameraNode;

    import com.jme3.scene.Node;

    import com.jme3.scene.control.CameraControl.ControlDirection;


  • @author Ziden


    public class RoundCamera {

    private final CameraNode camNode;

    private final int camDistance = 20;

    private float angle;

    private Character target;

    public RoundCamera(Camera cam, Character dude) {

    camNode = new CameraNode("CamNode", cam);


    camNode.setLocalTranslation(new Vector3f(camDistance/3, camDistance, camDistance/3));


    camNode.lookAt(dude.getModel().getLocalTranslation(), Vector3f.UNIT_Y);

    target = dude;



    private float angleAceleration = 0;

    private final float maxSpeed = 0.05f;

    public void acelerate(int dir) {

    if(dir==9 && angleAceleration < maxSpeed) {




    else if(dir==7 && angleAceleration > -maxSpeed)




    public void deacelerate() {

    if(angleAceleration!=0) {

    if(angleAceleration > 0) {

    angleAceleration -= 0.001f;

    if(angleAceleration<0) angleAceleration = 0;


    else if(angleAceleration < 0) {


    if(angleAceleration > 0) angleAceleration = 0;





    public void changeAngle() {

    angle += angleAceleration;

    // formula da bola

    angle %= FastMath.TWO_PI;

    camNode.setLocalTranslation(FastMath.cos(angle) * camDistance, camDistance, FastMath.sin(angle) *camDistance);

    camNode.lookAt(target.getControl().getPhysicsLocation(), Vector3f.UNIT_Y);




    Am i doing something wrong ? It seems so simple to me but it doesnt work right :frowning:

    I think now ive may be in the wrong way. Ive tryed to use ChaseCamera but i couldnt change how it worked to fit the way i intend to. It rotates right, does everything right, but generates that laggy render.

    Thank you alot for your time and patience, and for any help for soure :smiley:

    PS : My computer is a very good one so he aint the problem, 2gb video card.

What thread do you call the methods from? If you call them from an external thread (e.g. AWT button presses) then use callables.

1 Like

What u mean ?

Im not handling threads (yet), so i guess its all main threaded. Im using the default actionListener


inputManager.addMapping("MOVE.7",new KeyTrigger(KeyInput.KEY_Q));

inputManager.addListener(this, "MOVE.7");

// others

public void onAction(String name, boolean pressed, float tpf){

if(name.substring(0,4).equals("MOVE")) { // move.coisa


IO.rotateLeft= pressed;


// others



Then, at SimpleUpdate:

[java]if (IO.rotateLeft) {


} else if(IO.rotateRight)





Hope it explains more. Am i doing it wrong ?

Thanx alot for your help.