I’m trying to figure out a way that our FX artist can add FX to animations. Previous engines we’ve worked with have had animation editors that allowed artists to apply VFX and to frames within an animation. I was thinking that the new Animation Event tool ( http://docs.unity3d.com/Documentation/Components/animeditor-AnimationEvents.html ) would work well for this. If we can set scripted events to trigger on certain frames then we can just write scripts to play effects or sounds.
The documentation on this is kind of slim though and so far I haven’t found any answers from searching the forums.
Anyway, I’ve attached a screenshot of where I’m at. I have an animated character loaded, and the animation title (idle_test) shows up in the Animation Event tool, but there are no curves visible and all of the buttons are greyed out, including the Add Event button. I’ve tried just about everything I could think of at this point.
well for example if you are trying to add a event on a animation normally by default unity won’t let you do it because it’s coming from a 3d app rather than inside unity, so the way around this is to duplicate the animation clip then use the duplicate and you will be able to put animation events on it, keep in mind this is for the legacy animation system so if you are going to use mechanim to do this then it would be done using animations curves instead.
It looks like you’re using Mecanim. I don’t believe that Mecanim supports Unity’s Animation Events (the page you linked to) - they’re part of the legacy animation system.
If you want to stick with Mecanim, I believe the recommended approach is to set up custom animation curves and use them to indicate events - have them spike from 0 to 1 for a frame and poll the curve value in script.
Okay, thanks for the answers! I think copying the animations will cause some problems. It means any time an animation gets updated we’re going to lose all of the triggering that’s been done.
I think we may need to look into another way of doing this.
Just out curiosity though, how do you duplicate an animation clip. Is it something an artist can do in the editor or does it need to be done in code?
What you can do is store your trigger information in a text file next to the model, and then write editor scripts that automatically set them up on animation import (using the AssetPostprocessor class).
Using curve for single event kind of sucks - would be awesome if Unity could add “events” next to “curves” in animation settings. Would be even more cool if it could sync names of values, putting strings in plenty places is asking for painful bugs. And it could pull names of states as enum to animator instance… but I’m asking for too much.
What if because of some reason this frame (where curve is set to 1) is skipped? Can this happen? I set it for some time and then am using additional flag in script to mark isEventReceived - is it over cautious?