Alex10 Posted January 10, 2016 Share Posted January 10, 2016 How to make the appearance of a sound only when the moving mesh. I want to move the mesh only arrows. If I write "autoplay:true" the music plays regardless of the movement of the mesh. var ms = new BABYLON.Sound("Violons", "sounds/violons11.wav", scene, null, { loop: true, autoplay: true }); ms.attachToMesh(box);If I write "autoplay:false" the music is not playing regardless of the movement of the mesh. Example:http://www.babylonjs-playground.com/#7JOOL#9 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 10, 2016 Share Posted January 10, 2016 Hello, var ms = new BABYLON.Sound("Violons", "sounds/violons11.wav", scene, null, { loop: true, autoplay: true }); ms.attachToMesh(box);ms.stop(); use ms.play() when the movement of the mesh. Quote Link to comment Share on other sites More sharing options...
Alex10 Posted January 10, 2016 Author Share Posted January 10, 2016 I know.But if I set "autoplay: true" then the sound is played immediately after loading the scene without moving mesh.See the example http://www.babylonjs...nd.com/#7JOOL#9 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 10, 2016 Share Posted January 10, 2016 It works like this:var ms = new BABYLON.Sound("Violons", "sounds/violons11.wav", scene, function () { ms.stop(); },{ loop: true, autoplay: true }); Quote Link to comment Share on other sites More sharing options...
davrous Posted January 11, 2016 Share Posted January 11, 2016 I don't get it. If you need to play a sound only when you're moving the mesh associated to it, set autoplay to false and call the play method when you're moving it and stop or pause method when you're stopping moving it. autoplay is logically playing the sound automatically. ;-) Did I miss something? David Quote Link to comment Share on other sites More sharing options...
Alex10 Posted January 11, 2016 Author Share Posted January 11, 2016 If I assign on event keyUp start playing sound and hold down key, at the same time then start again a lot of sounds again and again.http://www.babylonjs-playground.com/#7JOOL#10Therefore, I ask, is it possible to do so when moving mesh was played sound? Quote Link to comment Share on other sites More sharing options...
davrous Posted January 12, 2016 Share Posted January 12, 2016 Ok, I think, you'd like to do that: http://www.babylonjs-playground.com/#7JOOL#12 Alex10 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.