n5ro / aframe-physics-system

Physics system for A-Frame VR, built on CANNON.js.
https://n5ro.github.io/aframe-physics-system/
MIT License
507 stars 138 forks source link

Sound fx on collision not working #142

Open StephanRodriguez opened 4 years ago

StephanRodriguez commented 4 years ago

Hello, I'm trying to play a sound on collision as specified here : []https://github.com/donmccurdy/aframe-extras/issues/48

The sound is an asset. I can't get it to work whatever I try. Here's my code : <a-entity grabbable draggable shadow dynamic-body="shape: Box; mass: 50" sound="src: ./Sons/chute.mp3; on: collide" class="colis" mixin="colis1" position="1 0.05 -2.5"></a-entity>

I wrote a component to test if collisions are detected :

AFRAME.registerComponent('collision_detection', { init: function() { var sound_fx = document.getElementById('chute'); this.el.addEventListener('collide', function (e) { sound_fx.play();}) } });

If the component is attached to my object, it plays the sound (endlessly), proving the collision is indeed detected.

Any help would be greatly appreciated. Thank you. Stephan

donmccurdy commented 4 years ago

Can you share a full demo? It seems like if the event is firing as expected, the problem is probably not in aframe-physics-system.