Hello,
Hello. I wanted to consult you for a problem that I researched and couldn’t find a solution to. There is a box that can be moved with the PG’dfe keyboard. The camera follows the box with setTarget but when I turn left or turn right the camera stays still. What I want is for the camera to stay behind box at all times. I request your help on the matter.
You’ll need to update the camera’s alpha in the opposite direction by the same amount. Like so;
if (keys.left) {
box.locallyTranslate(new BABYLON.Vector3(0, 0, -speed)) //D
box.rotation.y -= 0.03;
camera.alpha += 0.03;
}
2 Likes
Thank you for solition.
It was definitely the solution I was looking for. I would like to get your opinion on one more thing. I’m trying your solution on a different pc but it doesn’t work. What do you think could be causing the problem?
Third Person Example | Babylon.js Playground (babylonjs.com)
The second example is using a different camera type. The first was using an ArcRotateCamera the new is using a UniversalCamera.
1 Like