How do I [AUDIO] - stop sound instance

0 favourites
  • 9 posts
From the Asset Store
Make your gore effects come to life with this sounds! :D
  • I have multiple instances of a laser which can be turned on and off.

    I am playing a sound loop on each laser positionally. I want to be able to have the sound stop and start per instance of laser instead of a global tag of 'laser' which turns them all off and on.

    Any ideas?

    I want a flexible system because I've 100 levels with many configurations of these lasers already designed.

    Thanks!

  • You could convert the UID of the laser to a string and use that as the tag. That would make the tag unique per instance, even for the same sound.

  • You could convert the UID of the laser to a string and use that as the tag. That would make the tag unique per instance, even for the same sound.

    Ah yeah! Great idea I'll try that tonight Thanks so much!

  • You could convert the UID of the laser to a string and use that as the tag. That would make the tag unique per instance, even for the same sound.

    Just got round to trying this!

    Doesn't seem to work as intended - here's my code:

    And here's a demo demonstrating what's happening:

    https://youtu.be/w4BtLBK4gek

    As you can hear, the first object starts playing okay - but when the second activates the sound isn't being positioned on to it and I can't seem to stop the sound.

    Any ideas?

    Thanks!

  • Here's an example of it working. Click on the two sprites to start/stop the sound at each.

    http://www.blackhornettechnologies.com/ ... IDTag.capx

    I think you are having picking issues. I don't trust Trigger Once. I'd use a flag, like I've done, to actually control the sound. Or you can even see if the sound is playing already, to start/stop.

  • Here's an example of it working. Click on the two sprites to start/stop the sound at each.

    http://www.blackhornettechnologies.com/ ... IDTag.capx

    I think you are having picking issues. I don't trust Trigger Once. I'd use a flag, like I've done, to actually control the sound. Or you can even see if the sound is playing already, to start/stop.

    Yeah I'm really struggling with picking - here's my actual code in the way it makes sense to me:

    I can't seem to find a condition that isn't using trigger once to make the sound play only once as the laser, when it's turned off by shooting the button it waits 5 seconds and then switches on again, so I'm using 'isOn' variables etc.

  • It's completely unnecessary to try to detect when a variable has changed with 'Trigger once'. You changed the variable, you know when it happened. If the value gets changed in multiple places, then put the code in a function and call the function when the value changes. Or, you may not even need the variable anymore, just call the code.

  • It's completely unnecessary to try to detect when a variable has changed with 'Trigger once'. You changed the variable, you know when it happened. If the value gets changed in multiple places, then put the code in a function and call the function when the value changes. Or, you may not even need the variable anymore, just call the code.

    Ah man I'm just not getting this I'll upload a capx of what I'm doing if interested. Thanks for all the help by the way!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can PM me if you want.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)