ArcRotateCamera move camera with target

Hi everyone!

I’m trying to do something which I thought would be simple but that I’m surprisingly struggling with…
I’m animating an arcRotateCamera target with CreateAndStartAnimation.

The target moves as expected but I would like to “lock” the alpha, beta and radius of my camera or link it to the target so that when the target moves, the camera moves in parrallel.
I made a playground based on the ArcRotateCamera to test it out.
https://playground.babylonjs.com/#SRZRWV#404
When you press the space bar, the camera target will move towards the blue plane but the camera is not moving which currently makes sense.
I tried animating the alpha, beta, radius but that doesn’t seem to work. I tried to parent the camera to the target but Babylon doesn’t like it which also makes sense.

Let me know if you can think about anything else.

Thanks in advance for your help!

Chris

Hi Chris,

Animating “_target” instead of “target” works in the PG, maybe it would work in your project as well:

“target” is a setter, and it calls this function:

I don’t know if there’s a proper way to do this.

2 Likes

Well that was even easier than I thought :slight_smile: Thanks so much for your help.

Thanks so much for your help!

Chris

1 Like