cameraDirection speed


I have setup camera speed with

camera = new BABYLON.UniversalCamera("camera1", new BABYLON.Vector3(0, 2.3, 32), scene);
camera.setTarget(new BABYLON.Vector3(0, 0, 0));
camera.attachControl(canvas, true);
camera.speed = 0.5;

above speed works perfectly when I am moving with keyboard’s arrow keys.

I have a GUI button, which on hover I am forwarding camera like:

    if (isForwardBtnDwn) {

but camera speed is different there, how can I make .cameraDirection use camera.speed = 0.5 ?

a direction is normalized by default, you could simply scale it relative to the speed you want ?

1 Like

Also adding @PolygonalSun who is looking into inputs.

scaling camera? could you please see this PG

if you notice I have camera.speed = 0.3 , which works with keyboard arrow keys, but not with those GUI buttons, when you hover on button camera speed is different, may @Evgeni_Popov has some idea, since he helped me with inputs for this snippet.


@Cedric any help on this please?

Is it possible to get the inputmanager for the camera and ‘inject’ keys to simulate key downs?

1 Like

@sebavan, @Cedric thanks I just figured what I was doing wrong, I just had to properly scale, I was doing this ( see .scale(0.1))

which I had to scale like below ( see .scale(0.03)) to match with my camera.speed = 0.3;

1 Like