How do I play sound on a spesific moment

0 favourites
  • 8 posts
From the Asset Store
A set of board games to make your day joyful. Play, Enjoy, Relax
  • I got caught on a silly audio problem which im sure is laughably easy to remedy. Im trying to get the enemy AI grunt when he is hit by a bullet. Easy enough.. thing is, id like to play a different audio if he dies as i have a random value that deducts his energy to simulate that he can be either wounded or killed. For now he's just grunting even if he's killed.

  • give the enemy an instance variable. So if alive grunt if dead scream or whatever you have Or compare health. Greater than 0 = grunt and if zero play kill sound

    So on bullet collision with enemy


    if alive > play grunt

    if dead > play scream

  • Oh, i got it almost to work. I was overthinking it. Got it to play both sounds by doing an "on destroyed- play sound.."

    However, trying to finetune this a bit since the enemy can get a fatal shot from the first bullet, id like it to not give out the grunt which it now makes and also the falling to ground sound which i have set p as a dying sound. I dont know how to make the code work for me like that.

    https ://

  • Ok, then you have to setup so the grunt only plays when the enemy is not dead. So if you have different animations for that you can make the sound trigger on the correct animtaion like this:

    Live Demo ... index.html

    CapX ... sound.capx

    This is maybe not exactly how you would do in your project but the concept is the same and you should be able to get it to work with the correct triggers and conditions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • korbaach, thanks. But still cant get it to work with that. It starts playing the eeh sound in a kazillion times per second. I don't get it why it does that.

    Thanks Anonnymitet, that might do the trick. I haven't done any death animations yet but i have a strong feeling this is the way to go.

  • example.capx

    One Event and Two Sub-Events...

  • Okay, i tried it again your way korbaach and got it to work. I have no idea what was wrong since i just did it exactly the same way as before. Seems like sometimes starting from the beginnig on a clean slate helps Thanks to both of you!

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