- Home /
Record Animation at Runtime?
Hey guys! Hoping for some help with something...
I'm trying to figure out if it's at all possible for me to press play, and then record all of my main characters' movements during runtime as a new animation clip for playback later? I feel like this is something that should be able to be done, but I honestly just don't even know where to start...
Thanks in advance!
That shouldn't be too difficult to implement at runtime.
$$anonymous$$ake a special script that keeps a list of IDs or names of animations or such. Then, at your player controller script, each time a control is pressed that initializes a new animation, add new animation ID to the list of saved IDs. Then, simply assign a key to clear, and play back the saved animations.
That's as far as I figured what you're trying to achieve. If you need to make a new Animation clip asset for use in Editor itself, I see no reason why you can't chain wanted animation clips via $$anonymous$$echanim states. Simply don't put any transition condition, and enable Exit time for each state. That way they'll play end to end in a sequence.
@Rezzolution any update on this? trying to achieve kind of the same (kinect controlling avatar through the zigfu zdk, all my movements should be recorded in runtime for playback to my avatar later) but i can't seem to find any solutions.
Answer by newyellow · Mar 18, 2016 at 10:00 AM
Though it might be late now, I've done some script on this topic. https://github.com/newyellow/Unity-Runtime-Animation-Recorder
With this project, you can do just like you said: press play button and record all animation, and save to an .anim file, and you can even export it to .ma files for Maya.
Hope this helped!
Hello Newyellow,
Tried using the script, but when I do step 2: - Press "Set Save Path" button in the inspector, choose pick a folder and enter file name.
I am not able to click on save, it is non responsive. Can you help me fix this?
Thanks in advance!
Have you tried the demo scene and follow the video instruction?
If you do and it still happened, I'm not sure why. And since this save thing is not a custom script, it's Unity Editor's function, I can hardly help with it.
$$anonymous$$aybe check your Unity version? It has been test with Unity 5.4.x, all 5.x version should work fine.
And by the way, if you encountered any issue, you can report in the Github project page.
Newyellow,
I've just come across your script as well and look forward to trying it further. Have you come across any other similar products on the Asset Store similar to yours? I'm not on the program$$anonymous$$g side of Unity and it appears much of this type of things is out of my reach unless someone, like yourself, offers it up. Are there any limitations on what this can record?
Thanks!
It seems nothing similar in asset store, at least I didn't find any before I write this script. The record to .anim function is Unity's build in. Unity use it to build the Animation Recording thing, but they didn't offer runtime recording.
The limitation is, the recording function is not like 3D softwares like maya or 3D max. In maya or 3D max you can record things like Vertex animation, but this Unity Runtime Recording function can only record Transform's value changes, which are position, rotation and scale.
hey ny
I put the script on a character, expecting it to record the transforms of the children of the character(as in all the bones). But the FBX exports a file with file-size that tells me there is content in the file, but there is nothing to see.
The $$anonymous$$A export exports the thing all right, there is animation on ONE attribute on one of the many many nodes. It is not on a bone but rather a grp, and it just rotates left,right,left,right.
The $$anonymous$$A Exporter should work well. But you should notice the node's names. If there are two nodes with same name, that might cause errors.
hmm I had animation on all bones from the get go, so that definitely wasn't a good thing. Starting with a fresh character yields no better results though. $$anonymous$$y hierarchy looks like this
**char.ma**
char (grp)
L___ skeleton (grp)
. L___ joint1 (joint)
. L___ joint2 (joint)
. L___ joint3 (joint)
. L___ etc
L___ mesh (grp)
. L___ mesh1 (mesh)
. L___ mesh2 (mesh)
. L___ etc.
the same in the hierarchy in unity.
However the only thing that gets animation is the group called skeleton, which to makes no sense. And the animation is like this:
Also the chest is just rotated 115 degrees, no keys on it, nothing. Just a one time rotation.
the fBX exporter gives me this:
ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System.Collections.Generic.List`1[FbxDataNode].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633) FbxDataNode.FetchNodes (System.String inputData, Int32 level) (at Assets/Recorder/Unity Runtime Recorder/Scripts/FbxExporter/FbxDataNode.cs:71) FbxDataNode.FetchNodes (System.String inputData, Int32 level) (at Assets/Recorder/Unity Runtime Recorder/Scripts/FbxExporter/FbxDataNode.cs:51) FbxDataNode.FetchNodes (System.String inputData, Int32 level) (at Assets/Recorder/Unity Runtime Recorder/Scripts/FbxExporter/FbxDataNode.cs:51) FbxExporter+c__Iterator0.$$anonymous$$oveNext () (at Assets/Recorder/Unity Runtime Recorder/Scripts/FbxExporter/FbxExporter.cs:215) UnityEngine.SetupCoroutine.Invoke$$anonymous$$oveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/develop/UnitySource/Runtime/Export/Coroutines.cs:17)
The FBX exporter still has many things to work on. I just found another bug happens when your FBX original file already has animations, even just 1 or 2 frames. So make sure your FBX file contains exactly no animations. (When you put the file in Unity, the animation tab in the import setting is empty)
Thankyou so much for creating this package it has helped me immensely in recording $$anonymous$$inect movement. You should definately put it on the store for like $2 or something.
$$anonymous$$ay I suggest a FPS modifier for saving to anim
if (nowTime > (frameIndex) * (1 / (float)FPS)) {
for (int i = 0; i < objRecorders.Length; i++) {
objRecorders [i].AddFrame (nowTime);
}
if (recordBlendShape) {
for (int i = 0; i < blendShapeRecorders.Count; i++) {
blendShapeRecorders [i].AddFrame (nowTime);
}
}
frameIndex++;
}
Can make editing a lot easier
Thanks again for your contribution to the community
Answer by victorverg · Feb 23, 2018 at 03:05 PM
I'm wondering if there's any way to record Blendshapes as well? I'm looking for a way to record the iPhone X's face tracking data from the ARKit demo in runtime.
Answer by charlesjohney3 · Feb 15, 2018 at 10:37 AM
Hi.
I'd get a kick out of the chance to utilize the "Record Animation" highlight in the Game Engine where developments by a question at runtime are recorded to the protest's liveliness, yet for only one protest and not for the whole scene. Is it conceivable? http://www.flamingovideo.com/explainer-videos/
Answer by andreasng_pd · Feb 15, 2018 at 01:50 PM
Ok!
For anyone finding their way in here, these are the things you have to think about.
__1: Objects in maya should not be "frozen" in their relative spots, So an arm, for example, should be moved to 0,0,0 then frozen, then you can move the arm back up to where it should be. Don't know if that matters.
__1.2: I refrained from having a hierachy in the cut out character. So hand is not child of elbow which isn't child of upperArm etc etc. The ma file is just the cut out pieces, no containing group, no nothing.
__2: I gave up on an actual character. Instead I made a "cut out" character where the things I want to record has been cut out of the actual character. Then with playmaker (unity tool) I "get pos, get rot, set pos, set rot", on every single one of the limbs every frame, so they follow the joints of the character 1:1. Lo-fi, but it works. :)
__3: the recorded .ma file will make Unity crash, so don't let it start to import it. I move it out of the project immediately after recording. you have to set the export path to outside unity project.
__4: Use the .ma exporter. FBX does not help you set it up. Ma exporter has nice buttons and features. Remember to activate debug, so you can see when the thing actually records!
__5: The recorder takes a snap shot of the positions every frame, so when the game starts to slow down it seems like animation will go faster in the recorded footage. Because there is longer between steps in-game, but still only one time step between the recorded frames.
Your answer
Follow this Question
Related Questions
How to make pre-recorded character movements, then have them playout during a scene? 0 Answers
Children Object rotation/position get reset after Initializing Animation Recording 0 Answers
Unity2D - Playing animation with separte body parts/Setting Anchor point to sprites for each frame 0 Answers
Animation not looping 1 Answer
How to Serialize an AnimationState 0 Answers