First person camera shaking

Hi, i’ve been reading the topics about shaking camera problems but I can’t solve mine, and in fact it’s a very basic piece of code.

Basically, I’m trying to do a first person camera character that walks and jumps over a very simple floor (a large box).

It’s based on “” tutorial. The floor texture is “Pond.png” from the tutorial samples too. The problem is that in some parts of the floor and specially when i’m walking near its edges, the camera starts to shake terribly which doesn’t allow me to walk even in a straight direction. No problem when jumping.

This is the code:

[java]package mygame;


import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;

import com.jme3.bullet.control.CharacterControl;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.bullet.util.CollisionShapeFactory;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.material.Material;

import com.jme3.math.Vector2f;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.texture.Texture;

import com.jme3.texture.Texture.WrapMode;

public class Test1 extends SimpleApplication {

private BulletAppState bulletAppState;

private RigidBodyControl floor_phy;

private CharacterControl player;

private Vector3f walkDirection = new Vector3f();

private boolean left = false, right = false, up = false, down = false;

private Material floor_mat;

private static final Box floor;

static {

floor = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);

floor.scaleTextureCoordinates(new Vector2f(3, 6));


public static void main(String[] args) {

Test1 app = new Test1();




public void simpleInitApp() {

/** Set up Physics */

bulletAppState = new BulletAppState();





// Floor


// player

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);

player = new CharacterControl(capsuleShape, 0.05f);




player.setPhysicsLocation(new Vector3f(0, 15, 0));




public void simpleUpdate(float tpf) {

Vector3f camDir = cam.getDirection().clone().multLocal(0.6f);

Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);

walkDirection.set(0, 0, 0);

if (left) { walkDirection.addLocal(camLeft); }

if (right) { walkDirection.addLocal(camLeft.negate()); }

if (up) { walkDirection.addLocal(camDir); }

if (down) { walkDirection.addLocal(camDir.negate()); }





public void simpleRender(RenderManager rm) {

//TODO: add render code


protected Geometry makeFloor() {

Box box = new Box(new Vector3f(0, -1.2f, 0), 100, .2f, 100);

Geometry floor = new Geometry(“floor”, box);

box.scaleTextureCoordinates(new Vector2f(15, 15));


floor_phy = new RigidBodyControl(CollisionShapeFactory.createBoxShape(floor), 0.0f);



return floor;


public void initMaterials() {

floor_mat = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);

Texture tex = assetManager.loadTexture(“Textures/Terrain/Pond/Pond.png”);


floor_mat.setTexture(“ColorMap”, tex);


private void setUpKeys() {

inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));

inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));

inputManager.addMapping(“Up”, new KeyTrigger(KeyInput.KEY_W));

inputManager.addMapping(“Down”, new KeyTrigger(KeyInput.KEY_S));

inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));

inputManager.addListener(actionListener, “Left”);

inputManager.addListener(actionListener, “Right”);

inputManager.addListener(actionListener, “Up”);

inputManager.addListener(actionListener, “Down”);

inputManager.addListener(actionListener, “Jump”);


private ActionListener actionListener = new ActionListener() {

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

if (name.equals(“Left”)) {

if (keyPressed) { left = true; } else { left = false; }

} else if (name.equals(“Right”)) {

if (keyPressed) { right = true; } else { right = false; }

} else if (name.equals(“Up”)) {

if (keyPressed) { up = true; } else { up = false; }

} else if (name.equals(“Down”)) {

if (keyPressed) { down = true; } else { down = false; }

} else if (name.equals(“Jump”)) {







I need your help. Any ideas of what is happening?


A large box is not a good ground for the character, try using a plane or a mesh of some model.

thank you! that was the problem! I used a TerrainQuad and no more camera shaking

incredibly fast feedback!