grab animation sound trigger only once

rafhot

Member
hi i need help to solve one thing

my characters plays a classic kof "tick" sound when grab enemies ,but when press attack and grabattack starts in his end it goes back to grab animation and the "tick" sound trigger again and it hurts my ear
how to make it only trigger on the first time?
 
There's a work around for that with script. Let me try it myself first :)

[a day later]

Alright, here it is:

anim grab
@script
    void self = getlocalvar("self");
    int SFX = loadsample("data/sounds/clang.wav");

    if(getlocalvar("Grab" + self) != 1){
      setlocalvar("Grab" + self, 1);
      playsample(SFX, 0, 120, 120, 100, 0);
    }
@end_script
delay 10
offset 67 130
bbox 53 68 30 61
        frame data/chars/trix/stabU5.png

In this animation, clang.wav will be played when Trix grabs enemy. This SFX won't be played again until the local variable is resetted.
It's resetted in IDLE animation like this:

anim idle
@script
    void self = getlocalvar("self");

    setlocalvar("Grab" + self, NULL());
@end_script
loop 1
delay 10
offset 67 130
bbox 53 68 30 61
        frame data/chars/trix/idle1.png
        frame data/chars/trix/idle2.png
        frame data/chars/trix/idle3.png
 
Awesome work BB, one more time!!

Finally grab will have a sound ! and a well coded one!

Advice for some of you. I'm no more using "faint" anim, but for the ones who use it for low life stance, Don't forget to add the second script to faint anim too.
 
Back
Top Bottom