Rotate camera slowly to a target

I come from Unity background and if we want to move/rotate an object slowly to a certain position/rotation, we use Time.deltaTime in Update function. Is there a similar approach in Babylon? Such that by press of a key (Key.A), the camera moves/rotates slowly to a given position/rotation? The Vector3 will be set by me through code.

            var scene = new BABYLON.Scene(engine);
            // This creates and positions a free camera (non-mesh)
            var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 300, BABYLON.Vector3.Zero(), scene);
            // This targets the camera to scene origin
            camera.setTarget(BABYLON.Vector3.Zero());
            // This attaches the camera to the canvas
            camera.attachControl(canvas, true);

Hello,
You can use an animation to update the position of the camera target.
Take a look at the doc for more information:

You can find an example of a very basic camera’s target animation in my neon demo, at line 274 of the PG, I use CreateAndStartAnimation on the ‘target’ property of the camera:

Another way to do the same is to update the rotation/position in the render loop but I think using animation is the easiest way to do it.

2 Likes

If you want to do it without animations. The equivalent of Time.deltaTime in Babylon is engine.getDeltaTime(). You can update the camera in one of the events (e.g. scene.onBeforeRenderObservable).

1 Like

Sorry for the late reply. Can you please give an example of engine.getDeltaTIme()?
Such that the camera rotates to a target rotation (10,10,10).

Does a search in the playground help? If not, what specifically are you looking for?