Skip to content

Commit

Permalink
Check if current gain is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 24, 2024
1 parent 2a38a13 commit 889701f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/bit-systems/video-menu-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ function clicked(world: HubsWorld, eid: EntityID) {

const MAX_GAIN_MULTIPLIER = 2;
function changeVolumeBy(audioEid: EntityID, volume: number) {
let gainMultiplier = APP.gainMultipliers.get(audioEid) || 1;
let gainMultiplier = 1.0;
if (APP.gainMultipliers.has(audioEid)) {
gainMultiplier = APP.gainMultipliers.get(audioEid)!;
}
gainMultiplier = MathUtils.clamp(gainMultiplier + volume, 0, MAX_GAIN_MULTIPLIER);
APP.gainMultipliers.set(audioEid, gainMultiplier);
const audio = APP.audios.get(audioEid);
Expand Down

0 comments on commit 889701f

Please sign in to comment.