Animate Camera Target

I was looking around and cant find if its possible to animate the cameras target?

currently I am doing

var animation = new BABYLON.Animation("cameraSwoop",	"position", 30,
				BABYLON.Animation.ANIMATIONTYPE_VECTOR3)
var keyFrames = []
keyFrames.push({
					frame: 0,
					value: camera.position.clone()
				})
for(var i=1; i<=path.length; i++){
				var ap = path[i-1]
				keyFrames.push({
					frame: step*i,
					value: ap
				})
			}
animation.setKeys(keyFrames)
camera.animations = [animation]
animation = scene.beginAnimation(camera, 0, step*path.length, false, 1)

and use a secondary observer to set the target, only problem is it makes a nasty jump on the initial set target where the camera does not smoothly pan to the target.

I found the old thread where I do it manually on the old forum… but I don’t wanna do that again.

1 Like

UPDATE

Oooooo I know, Ill make a hidden camera target node and animate that to the target at the same rate that the camera position animation is running. Then just set the target to the node.

UPDATE of UPDATE

This worked like a charm!

3 Likes

Heya Could you maybe share playground? Need to do something similiar and curious how you achieved it

1 Like

https://www.babylonjs-playground.com/#UU7RQ#593

2 Likes

Just wanted to say it’s possible to animate the camera target without creating a hidden target node. We just need to pass in “target” as the targetProperty for the animation. And don’t forget to specify BABYLON.Animation.ANIMATIONTYPE_VECTOR3 as the animation dataType (that’s why it wasn’t working for me :man_facepalming: :man_facepalming: :man_facepalming: )

Example here.

Btw, sorry to revive this topic. This was the 1st google result for “babylonjs animate camera target”, so I thought I’d add this information here.