I’m still working on making a proper a third Person camera for my project and recently came across this playground:
The implementation is what I’m looking for but I’m having trouble translating it to be used with an imported glb that uses animation groups instead animation ranges. Any insight?
My original implementation was using an Universal Camera and updating the position within an updateCamera() function like show:
const updateCamera = (camera, target) => {
const offset = new BABYLON.Vector3(0, .5, -3);
const desiredPosition = target.position.add(offset);
var distance = BABYLON.Vector3.Distance(target.position, camera.position);
player.computeWorldMatrix(true);
const targetPosition = player.getAbsolutePosition();
/* Set camera's Y position to anything you'd like */
targetPosition.y = 1;
camera.target=targetPosition
// Use interpolation (lerping) to smoothly move the camera to the desired position
camera.position = BABYLON.Vector3.Lerp(camera.position, desiredPosition, 0.1);
target.position = new BABYLON.Vector3(player.position.x, player.position.y + 1.3, player.position.z);
};r
but I hadn’t figured out how to add the player rotation logic or orbital behavior to the camera.