mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 21:03:17 +02:00
Also rate limit the bubble sound
This commit is contained in:
parent
1bda3faaf2
commit
13d8d643f7
1 changed files with 13 additions and 6 deletions
|
@ -16,6 +16,8 @@
|
||||||
var button;
|
var button;
|
||||||
// Used for animating and disappearing the bubble
|
// Used for animating and disappearing the bubble
|
||||||
var bubbleOverlayTimestamp;
|
var bubbleOverlayTimestamp;
|
||||||
|
// Used for rate limiting the bubble sound
|
||||||
|
var lastBubbleSoundTimestamp = 0;
|
||||||
// Used for flashing the HUD button upon activation
|
// Used for flashing the HUD button upon activation
|
||||||
var bubbleButtonFlashState = false;
|
var bubbleButtonFlashState = false;
|
||||||
// Affects bubble height
|
// Affects bubble height
|
||||||
|
@ -38,6 +40,7 @@
|
||||||
|
|
||||||
var BUBBLE_VISIBLE_DURATION_MS = 3000;
|
var BUBBLE_VISIBLE_DURATION_MS = 3000;
|
||||||
var BUBBLE_RAISE_ANIMATION_DURATION_MS = 750;
|
var BUBBLE_RAISE_ANIMATION_DURATION_MS = 750;
|
||||||
|
var BUBBLE_SOUND_RATE_LIMIT_MS = 15000;
|
||||||
|
|
||||||
// Hides the bubble model overlay and resets the button flash state
|
// Hides the bubble model overlay and resets the button flash state
|
||||||
function hideOverlays() {
|
function hideOverlays() {
|
||||||
|
@ -49,11 +52,15 @@
|
||||||
|
|
||||||
// Make the bubble overlay visible, set its position, and play the sound
|
// Make the bubble overlay visible, set its position, and play the sound
|
||||||
function createOverlays() {
|
function createOverlays() {
|
||||||
Audio.playSound(bubbleActivateSound, {
|
var nowTimestamp = Date.now();
|
||||||
position: { x: MyAvatar.position.x, y: MyAvatar.position.y, z: MyAvatar.position.z },
|
if (nowTimestamp - lastBubbleSoundTimestamp >= BUBBLE_SOUND_RATE_LIMIT_MS) {
|
||||||
localOnly: true,
|
Audio.playSound(bubbleActivateSound, {
|
||||||
volume: 0.2
|
position: { x: MyAvatar.position.x, y: MyAvatar.position.y, z: MyAvatar.position.z },
|
||||||
});
|
localOnly: true,
|
||||||
|
volume: 0.2
|
||||||
|
});
|
||||||
|
lastBubbleSoundTimestamp = nowTimestamp;
|
||||||
|
}
|
||||||
hideOverlays();
|
hideOverlays();
|
||||||
if (updateConnected === true) {
|
if (updateConnected === true) {
|
||||||
updateConnected = false;
|
updateConnected = false;
|
||||||
|
@ -79,7 +86,7 @@
|
||||||
},
|
},
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
bubbleOverlayTimestamp = Date.now();
|
bubbleOverlayTimestamp = nowTimestamp;
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
updateConnected = true;
|
updateConnected = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue