Adding sound to a mesh in the editor


I am working in the editor would like to trigger a sound by clicking on a mesh.
Here is what I have attempted that hasn’t produced the desired results:

  • “Add sound” from top menu, load “biff.mp3” from “scene” folder into assets. The sound loads fine and I can play it from the inspector.
  • Click “attach to mesh” in the sound inspector, and attach to the mesh “dotsphere” (not sure what this did, nothing seemed to happen)
  • Create a new script “MeshSound” and paste in code from this example where the script says “// Your code…” (edited to use “biff.mp3”) & attached this to desired mesh
  • Ran example and the sound script didn’t seem to do anything, the the other “play” script for animation works fine.

Thanks in advance for your help, Babylon denizens!

Pinging @julien-moreau

Hey @Yam!

Thanks for reporting that issue! As I can see, you are using the Editor v3 and it looks like you just started using the Editor for you project.

What I suggest now is that you give a try to the Editor v4. It has been made to be more powerful/stable than the v3 and I’m pretty sure it’ll more fit your needs :slight_smile:

You can download the Editor’s beta here: BabylonJS Editor v4.0.0 beta · BabylonJS/Editor Wiki · GitHub
And find some documentation still WIP here: Editor/ at release/4.0.0 · BabylonJS/Editor · GitHub

You can follow that documentation to add a sound and attach it to a mesh: Editor/ at release/4.0.0 · BabylonJS/Editor · GitHub

And then, simply add a script following that documentation: Editor/ at release/4.0.0 · BabylonJS/Editor · GitHub

You’ll be able to get the sound reference using “sceneReference.getSoundByName(“files/sound_name.mp3”)”

Let me know if you have any problem or feedback, it’ll be a pleasure :slight_smile:


I forgot to thank you for this earlier, so thank you! Links to v4/documentation got me un-stuck :slight_smile: