Changing the increments of camera movement when using the keyboard

Hello,
is there a way to change the increments by which the camera moves when I use the arrow keys on the keyboard?
Also:
I’d like to create an on-screen keyboard control representing the arrow and zoom keys.
Do i need to write my own camera control handler for that, or can I tap into the existing methods called by the keyboard?

Thanks a lot.

I totally depends on the type of camera you are using so a tiny playground would help but there are usually various controls to change keys or speed on all of them

I am using the ArcRotateCamera:
Created a playground here:
https://playground.babylonjs.com/#R2PXZA#4
I would like to call the same functionality for the buttons that the hardware kayboard keys are using.
Thanks!

So I messed around with this and added:

let pos = camera.position.clone();
pos.z+= 0.5;
BABYLON.Animation.CreateAndStartAnimation("cameraAnimationZ", camera, "position", 60, 120, camera.position, pos, 0);

In the zoom Button Handler
That does not do anything unfortunately.
I guess I am missing something?
here is the playground:
https://playground.babylonjs.com/#R2PXZA#5

Your main issue is that you animate camera but in your importMesh function you are actually creating another camera with createDefaultLightOrCamera. You should animate the newly created one.

Just as an FYI, if you use the default camera controls and want to adjust the speed of camera movements, you can reference the keyboard inputs directly and modify the angularSpeed

var camera = // Your ArcRotateCamera
...
// Default speed is 0.01
camera.inputs.attached.keyboard.angularSpeed = 0.01
1 Like

Thanks a lot @PolygonalSun , I focused too much on the second question I forgot of the first one :slight_smile:

Hello and thanks for all the info.

That happens when one copy and pastes in a hurry … :roll_eyes:

After I fixed it, the animation works.
So I tried to recreate the movement that happens when one uses the keyboard right arrow key ( rotation along the x-axis ) with the following code:

let pos = camera.position.clone()
pos.x+= 2;
BABYLON.Animation.CreateAndStartAnimation("cameraAnimationX", camera, "position", 1, 1, camera.position, pos, 0);

However that does not produce my intended results.
See here:
https://playground.babylonjs.com/#R2PXZA#7
Maybe I should just copy what I find in the source for the keyboard input?

Thanks. Well, I intentionally do not want to use the keyboard controls.
I need to recreate the same functionality with on-screen buttons.
The final application will run on a touch-device with limited capabilities.

Edit:
I am sorry but I guess mixing two different questions is a bit confusing.
Edit 2:
So I did check the source and the simple solution is just:

camera.inertialAlphaOffset += 0.01;

as seen here:
https://playground.babylonjs.com/#R2PXZA#8