// Add events at specific frames
jumpAnimation.addEvent(new BABYLON.AnimationEvent(
10, // Frame number
function() {
// Event callback
console.log("Starting to jump");
// Play sound
const jumpSound = new BABYLON.Sound("jump", "sounds/jump.mp3", scene);
jumpSound.play();
}
));
jumpAnimation.addEvent(new BABYLON.AnimationEvent(
50, // Frame number
function() {
console.log("Landing");
// Play landing sound
const landSound = new BABYLON.Sound("land", "sounds/land.mp3", scene);
landSound.play();
}
));
// Apply and play
box.animations = [jumpAnimation];
scene.beginAnimation(box, 0, 60, true);