Search code examples
camerasmoothingbabylonjs

BabylonJS - Remove smooth animation on the camera


I'm using BabylonJS to make a little game.
I'm using this code to build a camera :

this.cam = new BABYLON.FreeCamera("playerCamera", new BABYLON.Vector3(x, y, z), s);
this.cam.checkCollisions = true;
this.cam.applyGravity = false;
this.cam.keysUp    = [90]; // Z
this.cam.keysDown  = [83]; // S
this.cam.keysLeft  = [81]; // Q
this.cam.keysRight = [68]; // D
this.cam.speed = v;
this.cam.ellipsoid = new BABYLON.Vector3(1, h, 1);
this.cam.angularSensibility = a;

And it works, i have a camera, i can move around ect ...
But my problem is here : by default they are a smooth animation when a move and when i change the orientation of the camera.
Let me explain : When i move with my arrow keys (aproximately 20 pixels to the left) it will go to 25 pixels (20 pixels + 5 smooths pixels).
I don't want it :/ Do you know how o disable it ? (To move and change orientation of the camera).


Solution

  • This is due to the inertia defined in the free camera.

    To remove this "smooth" movements, simply disable inertia:

    this.cam.inertia = 0;