content/hifi-content/caitlyn/scratch/linkJumpSound.js
2022-02-13 22:19:19 +01:00

25 lines
No EOL
725 B
JavaScript

(function() { // For entity scripts, we wrap it in an anon function
var isJumping = false;
var jumpSound;
this.preLoad = function(entityID){
print("Preload");
jumpSound = soundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/missle+launch.wav");
};
function checkJump() {
var currentJumpState = (MyAvatar.isInAir() && !MyAvatar.isFlying() && MyAvatar.velocity.y > 0.1);
if (isJumping !== currentJumpState) {
isJumping = currentJumpState;
if (isJumping) {
print("JUMP DETECTED");
Audio.playSound(jumpSound, {position: MyAvatar.position,volume: 0.5});
}
}
};
function onUpdate() {
checkJump();
};
Script.update.connect(onUpdate);
})