I made the sound work for my game, but when I hold down the button(s) it repeats the sound, and it kinda gets annoying. (you press U+O to turn on engine, J to turn off. Do that a couple times, and you will hear what I mean)
https://launch.playcanvas.com/1658065?debug=true
Normally I would suggest to replace isPressed
with wasPressed
or wasReleased
, but I’m not sure if this works with two keys at the same time. You can give it a try.
Maybe if I make a separate entity for the sound (if this [random word] is true this sound play [sound] else this sound stop [sound]) or maybe make a child entity.
Maybe the example below is a better solution.
if (!this.entity.sound.slot('shoot').isPlaying) {
this.entity.sound.play('shoot');
}
Thank You ! it works better now.