I’m using an Animator track to transition between animation clips for a 3D actor. For example, walk/run/idle, etc. One of the clips has the character typing on a computer. When he’s typing, I play a corresponding sound effect. Currently I’m doing that via Property track, setting a boolean to true/false. However, that’s kind of annoying. Ideally, I’d always play the Typing sound effect whenever the character is performing the Typing animation.
I looked though the AnimatorTrack code, and I don’t see any events getting raised, so I assume I can’t easily get at this functionality. But my ideal case would be some event I could listen for that gets raised whenever my track activates my Typing animation clip, and similar raises another event when the clip is deactivated. Just checking whether there’s any way currently to tie into that functionality without manually editing the AnimatorTrack code.
I could probably add some events for when a clip is activated/deactivated (not only for Animation Clips), but why not play the audio with the Audio Track in slate. Is the reason to avoid extra clips, since you only want this audio to be played tied with the animation?
Another solution would be to add Animation Events to the animation itself in the usual way of adding Animation Events in Unity. With that said though, there is a small bug currently that prevents Animation Events from being called, but which can easily be fixed by commenting out line #205 masterMixer.Pause(); in AnimatorTrack_2017.cs .
Let me know if using Unity AnimationEvents for that works for you, or if you still would prefer an onActionClipEnabled and onActionClipDisabled event in Cutscene class (static events).
Thanks for the suggestion. I’ll have to give the animation event approach a try with the code modification you pointed out. My concern with animation events is whether it would be reliable given the way Slate blends animation clips, and the possibility of offsetting the animation start time. For example, if I add an animation event to frame 1 of my “typing” animation clip, and blend that animation in with a preceding clip, will the frame 1 event be fired? I’ll do some testing on that.
And to answer your specific question, the reason for wanting this kind of functionality is because I have a certain set of animations that are always accompanied by some sound effects. For example, the “typing” animation should always trigger a “typing” sound effect to play. Walking is another example. Right now I’m independently starting the animations and the sound effects, and so a change to the animation requires that I realign the sound effect clips as well. Not the end of the world, but something I’d prefer a unified approach for.
From the tests I’ve just done, yes, the events are correctly called in all those situations (clip offset, blending, as well as looping the action clips), so that’s a good thing 🙂
I totally understand what you are saying and agree with you. It’s certainly better if animation and their effects like audio are unified as best as possible. Let me know if Animation Events work for you, or if adding some events for when clips enable/disable would better suit your needs.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.