Hello everyone,
I’m working on an AR project in 8th Wall Studio (Beta). The idea is the player will be able to walk around outside and clay pigeons will spawn around them and the player can “shoot” them.
I have this system more or less working, so I thought it would be a good idea to start adding some audio to it.
import * as deathSound1 from './assets/Audio/kbhp.m4a'
import * as deathSound2 from './assets/Audio/kblp.m4a'
import * as deathSound3 from './assets/Audio/kbn.m4a'
I’m following along with (1) Niantic Studio Workshop: Game Mechanics Basics - YouTube for implementing some audio sounds for when the player has shot one of the clay pigeons.
However, as soon as I add these lines to my clay pigeon component the console gives me the following error:
[tsl] ERROR in /tmp/src/wbd.wonderment-phyics-concept/clayPigeon.ts(3,30)
TS2307: Cannot find module './assets/Audio/kbhp.m4a' or its corresponding type declarations.
ERROR in /tmp/src/wbd.wonderment-phyics-concept/clayPigeon.ts
./clayPigeon.ts
[tsl] ERROR in /tmp/src/wbd.wonderment-phyics-concept/clayPigeon.ts(4,30)
TS2307: Cannot find module './assets/Audio/kblp.m4a' or its corresponding type declarations.
ERROR in /tmp/src/wbd.wonderment-phyics-concept/clayPigeon.ts
./clayPigeon.ts
[tsl] ERROR in /tmp/src/wbd.wonderment-phyics-concept/clayPigeon.ts(5,30)
TS2307: Cannot find module './assets/Audio/kbn.m4a' or its corresponding type declarations.
Now, I honestly feel really silly asking about this because it should be very straightforward.
I’ve also tried to, instead of importing like above, directly implement the audio url path in code like so:
function playDeathSound() {
const randomChoice = Math.random()
let audioClipUrl = ''
if (randomChoice <= 0.33) {
audioClipUrl = './assets/Audio/kill_bird_normal.m4a'
} else if (randomChoice >= 0.66) {
audioClipUrl = './assets/Audio/kill_bird_higher_pitch.m4a'
} else {
audioClipUrl = './assets/Audio/kill_bird_lower_pitch.m4a'
}
ecs.Audio.set(world, eid, {
url: audioClipUrl,
})
console.log('play death sound: ', audioClipUrl, eid)
}
This doesn’t throw any errors in the console, but no audio is played either. The console log outputs what I would expect here, being a selected audio file path + which entity it should have triggered on.
Any advice on how I might approach this would be appreciated. Thank you.