Saturday, February 18, 2012

skipping the obligatory intro post, let's dive right in

        So i've been getting my hands dirty with Unity again in a pretty big way.  Seriously, now that i've left the games industry, i'm actually making...well game-ish type things again, and somewhat having fun in the process.  Oh who am i kidding, this is probably the most fun I've had in the last 5 years or so.  Can't put too fine a point on what I'm doing at the new gig, but suffice it to say I'm doing some interaction design stuff that draws heavily on my experience in game development.  It's fun.

        But I'm not here to tantalize or be faux subversive in a rather clumsily veiled attempt to get people to ask me for more information.  Rather, I think i'm going to use this space to share random tips I come across during my game-ish interaction prototype development experience.  Probably some Unity randomness, tons of Maya randomness, and who knows, maybe some of that Python stuff i seem to love so much.

        Alright then, as the title states, let's dive right in.  One of the really interesting things I came across in the Unity reference manual:

"The most convenient way for animators to work is to have a single model containing all animations."

        Hmm...my 10+ years supporting animators in various degrees tells me otherwise, so of course I setup my character with individual animation files.  No referencing or anything pretty like that, this is a pretty quick n dirty project, so no infrastructure or pipe really.  We'll make that up next project, but that's for another post.  Anyway...

        If you're familiar with Unity, you may be aware that when you import an animation, it comes in as a Read-Only asset.  In short, it means you can't add animation events or otherwise edit the animation in Unity.  After a few hours, well ok, maybe only one, I found the accepted workaround, which is to duplicate the animation clip and thereby creating a new animation clip that's writeable.  I quickly found out that many of the explanations i found online where contingent on creating animation the Unity approved way, i.e. one long animation file.  That gives you an asset with a bunch of animation clips as children, like so:


         With this layout, it's pretty easy to break the Read-Only state, you simply select the clip and Edit > Duplicate or Ctrl+D and you're good to go.  The toolflow issues arise when you want to make an animation clip Read-Only and the animation is stored in a separate file.  In that case, you get an asset that looks something like this:


        In this case, you have actually have a bunch of individual assets that Unity collates into a single-ish asset.  The question now is how do you duplicate one of these to break the Read-Only state?  Well, selecting the actual asset and duplicating doesn't do it, it just creates another Read-Only animation entry.  We can attempt to duplicate the entry in the Inspector:


       ...But that just gives us the same end result:(  So what's a bear to do??  Good question, the secret actually lies in the animation asset's hierarchy.  If we expand one of the animation assets, we get all sorts of fun things:


        If we look down near the end of the animation asset's children, we find what we seek, the actual animation clip itself.  THAT'S what we want to duplicate, so we select that and Edit > Duplicate or Ctrl+D.  Now we have a discreet instance of the animation clip:


        Now we just have to drag this instance into the appropriate slot in the character's Animation block in the Inspector, and we're good to go:


        Now we can add Animation Events to our heart's content.  Keep in mind we lose all this data when we reimport, so it's probably a good idea to come up with some sort of automated process for this.  Good case for some sort of metadata system...Maybe we'll talk about that at some point, I do need to learn Unity Editor Scripting, but honestly, I have no idea when I'm going to get back to building big systems again.  So anyway, that's what I got for now, like i said, it's a pretty specific case, but I imagine i can't be the only person who's ever run into this.  Hopefully this helps.

        Hope someone found this useful, next up, some thoughts on SoftKinetic and the iisu SDK...Stay Tuned!