- Home /
multiple Animation Events in an Animation
Hello,
I have an attack animation, where the character does four slashes with his sword.
Is it possible to do all four animation events integrate into the animation via one function?
function SwingEvent()
{
var swingEvent = new AnimationEvent();
var swingEvent2 = new AnimationEvent();
swingEvent.functionName = "swingSound";
swingEvent.time = 0.0;
animation["attack"].clip.AddEvent(swingEvent);
swingEvent2.functionName = "swingSound2";
swingEvent2.time = 2.0;
animation["attack"].clip.AddEvent(swingEvent2);
}
function swingSound()
{
audio.volume = 1;
if(!audio.isPlaying)
{
audio.clip = swing_aud[Random.Range(0, swing_aud.length)];
audio.Play();
}
}
function swingSound2()
{
audio.volume = 1;
if(!audio.isPlaying)
{
audio.clip = swing_aud[Random.Range(0, swing_aud.length)];
audio.Play();
}
}
It isn't working, I'm a bit unsure how the script works.
Thank you Griffo for the template.
Comment
Did you get this working?? i have a similar question and rather not re ask it.