How do I animate a character in the Unity editor?

How do I animate a character in the Unity editor?

PostPosted by MikeC » Wed May 30, 2012 5:44 pm

What I would like to do is move a character along a path in the Unity editor, to help designers construct camera animations which match the character motion. I have written the code to follow a path which runs during game play, but I've run into problems trying to get it working in edit mode.

My first attempt to accomplish this involved tagging the generated Game Controller script with [ExecuteInEditMode], but any attempt to change parameters such as Speed result in the following error:

[Sage] Trying to call GetFloat on a Sage Controller with no library!

I suspect I need to add some explicit initialization somewhere, but I'm not sure where.

After working with the Sage Testing GUI, it is obvious that a character can be animated in the editor, but the steps I need to take to set up a controller for the animation in the editor aren't clear.
MikeC
 
Posts: 2
Joined: Wed May 30, 2012 5:01 pm

Re: How do I animate a character in the Unity editor?

PostPosted by AlteredReality » Fri Jun 01, 2012 7:43 pm

Are you talking about using a Sage Library without clicking on the "Play" button in the editor? The "Start" button in the Sage editor puts the editor into animation mode, similar to the animation editor for unity. And then plays things back using the editor update calls. I have never worked with [ExecuteInEditMode] before.

However, if you want to try and initialize it in edit mode, you would need to call Awake() on the controller to create the Sage library. This is not something I support, and I have never worked with it in this way. So I'm honestly not sure if it will work or not.

Have you tried this? Can you let me know if this works for you? I'd be very curious to know how it turns out. Thanks!
Andy - Altered Reality
AlteredReality
Site Admin
 
Posts: 118
Joined: Fri Jan 06, 2012 8:31 pm

Re: How do I animate a character in the Unity editor?

PostPosted by MikeC » Mon Jun 04, 2012 12:54 pm

Yes, I'm trying to run the sage library without clicking Play.

I've solved the lack of sage asset library reference, that turned out to be a problem with my initialization code.

My controller with [ExecuteInEditMode] seems to initialize correctly now. I've added it's update function to the EditorApplication.update event so I get per frame script calls. However, nothing much happens. I think this is an elapsed time issue, because when the editor is not in play mode, Time.time always returns 0. So, the character never really starts animating.

Now, to get elapsed time in edit mode, I can use EditorApplication.timeSinceStartup, but there's no way for me to feed this time source into the Sage library.

I would like to get interactive editing of animations and character motion working, so I might take a different approach of doing the editing in play mode, and somehow saving the changes made during the play mode.
MikeC
 
Posts: 2
Joined: Wed May 30, 2012 5:01 pm

Re: How do I animate a character in the Unity editor?

PostPosted by AlteredReality » Mon Jun 04, 2012 3:09 pm

Beyond playing back animations in Sage visual debug mode (by pressing the Start button in the Sage Editor), this is not something we are going to directly support. Getting the character to animate without being in play mode for the visual debug mode was something that took a while to get working for Sage. This was due to exactly how you needed to make things animate outside of playmode, as it was very different than playing it back while the game was running.

However, what you want to do seems like it would be possible to do. You would require the source code and someone with the time put into creating the feature, but the Sage source code would give you a good starting point. You'd pretty much have to look at how we did the visual debug mode, and make your feature based off of that.

Let me know if you have any more questions.
Andy - Altered Reality
AlteredReality
Site Admin
 
Posts: 118
Joined: Fri Jan 06, 2012 8:31 pm


Return to Questions and Discussion

Who is online

Users browsing this forum: No registered users and 0 guests


Style by Gokinstudio | Free forum hosting by ProphpBB | Software by phpBB | Report Abuse | Privacy
cron