Git Product home page Git Product logo

unity-runtime-animation-recorder's Introduction

Unity-Runtime-Animation-Recorder

This project can make you recording animations in runtime with Unity, and can save into .anim or Maya .ma format.
Though Maya has its own physic simulator, but unity is much faster and can easily control detail movement through scripts.

Installation

Copy just copy Unity Runtime Recorder folder into your Asset folder and it's ready to go.
If you want to see same sample you can also copy DemoAssets folder.

How To Use

Here is a short video demo.
https://youtu.be/RAjU5KodE1w

Unity Anim Saver

※ this function needs UnityEditor to work, so can only work in the Editor.

  1. Drag the UnityAnimationRecorder.cs script on any GameObject, and it will record all transforms in children.
  2. Press "Set Save Path" button in the inspector, choose pick a folder and enter file name.
  3. Play the scene, and start/end recording by press the key you set in the inspector.
  4. When End Recording pressed, the .anim file will be generated.

Maya Exporter

Pretty much the same as Unity Anim Saver.
Additionally, you have to select an .ma file which contains all model information.

My script doesn't generate model informations for maya, it only record animation data and append them at the end of .ma file. If you want to export the meshes you make in Unity, you can try Export2Maya which is a nice plugin I use before.

Export Humanoid Animations to Maya

※ This step is no longer needed, the script will solve this problem automatically. But since this section explains the problem and the solution, so not remove it.

Unity and Maya treat spines differently, which sometimes cause issues when you exporting animation with SkinnedMesh.

In Maya, there is an additional "Joint Orient". The actual spine rotation is the sum of transform rotation and joint orient. But since Unity doesn't have this attribute, the transform rotation values in Unity is alreay the sum value. While this plugin is recording the values in Unity, the joint orient values will add once more in Maya, cause the recorded result weird.

In order to record animation correct, we have to make every spines' "joint orient" values to (0,0,0). And here is a tutorial video if you not sure how to do it.

Export Humanoid Animation from Unity to Maya - Unity Runtime Animation Recorder
※ Now the Maya Exporter script will set all spines' joint orient to (0,0,0), which solves this problem automatically.

FBX Exporter

2017-10-10 Implemented FBX exporter, works similar as Maya Exporter.
But for now, there is some memory issue, can't export too complex objects.

 Export to FBX Demo Video

Here are a few things to notice:

  1. The "source FBX file" has to be in ASCII format (you can choose ASCII or Binary while exporting FBX file)
  2. Make sure every nodes' name are exactly the same as the source file
    (sometimes nodes' name got changed by Unity or 3D software)  

Dealing with Lag

If you want to simulate with a big amount of objects, you might ecountered lag.
You just need to adjust the Time.timeScale value in the Project Setting (or by using ChangeTimeScale option in my script).

All physics in Unity will affect by timeScale setting. And if you want to modify the object animation through your own script, please use FixedUpdate instead of Update.

License

MIT

unity-runtime-animation-recorder's People

Contributors

newyellow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-runtime-animation-recorder's Issues

Issue recording mutliple animations

If I record one animation by pressing "Start" and "Stop" it works great.

When recording more animations, e.g. by pressing "Start", "Stop", "Start", "Stop" and changing the filename inbetween the second animation will consist of the first and the second one. I this expected behavior?

When I used "FBX Exporter", I got error message

When I used "FBX Exporter", I got error message.
The error message is like below.

ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
System.String.Substring (System.Int32 startIndex, System.Int32 length) (at <437ba245d8404784b9fbab9b439ac908>:0)
FbxObjectsManager.EditTargetFile (System.String targetFilePath) (at Assets/Unity Runtime Recorder/Scripts/FbxExporter/FbxObjectsManager.cs:28)
FbxExporter+d__22.MoveNext () (at Assets/Unity Runtime Recorder/Scripts/FbxExporter/FbxExporter.cs:347)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <480508088aee40cab70818ff164a29d5>:0)

What is the problem and how can I solve this problem??

Unity Animation recorder not working...

It appears as if the animation recorder is not working. I'm on Unity 5.4.1f1 and whenever I try to record an animation, the animation clip would only have 2 curves and wouldn't have that I actually recorded...
image
I have this spectrum that reacts to audio, and what I used to do in Unity 5.4.0 was that I would record it and the Animation recorder would return a relatively large file that would usually have these settings:
image
Now, this is what I'm getting from the animation recorder:
image
There's also no errors or warnings in the console, so I have no idea what's happening...

Edit:
For the sake of experimentation, I put 50 spheres as a child to a gameObject with only the Animation recorder on it and recorded the falling from the rigibody component. I then took the rigibody out and put the animation clip on the parent object. It seemed to work...

Edit 2:
I even recorded the falling of 100 spheres and even that seemed to work...

Edit 3:
I found out that the cubes aren't recording because they all have the exact same name... I'll close this issue, sorry about that haha

file size and limiting bones.

Hello, I'm looking at baking some simulated bones with this and am starting to update your scripts to allow for only recording bones specified by an avatarMask and to limit the recording framerate for 15fps. Basically I need to shrink the .anim file (don't need keys for position and scale on every frame).

Before I dive too far, I thought I'd check if you or anyone has already done this.

Could not find part of path

Hello,

I am getting an error in the console when attempting to export an animation to Maya:
DirectoryNotFoundException: Could not find a part of the path "C:\Users...\REF_translateX_dataTemp"

I saw the suggestion on your YouTube channel on how to correct exporting a humanoid animation but I am still running to the issue on nodes that are only 3 characters long. I am not certain on where to edit the recorder script either based on your second solution. I am hoping to get a bit more info so I can get this working.

Thank you!

Thanks!

No issues at all, I just wanted to say THANKS!

This is exactly what I was looking for! Massive time saver!

Feel free to close after reading and apologies for opening a "Fake" issue 🙂

Demo Scene of Humanoid Animation Export?

newyellow, any chance you could add a demo scene to show how this can successfully work? I have been trying to get this working in a few different ways but my .ma file still keeps mangling the skeleton. I believe I am using the most recent version after I saw the note about the script zeroing out the joint orient values. I'm curious if I'm just doing one step wrong and am just not seeing it. Would you be able to test out the original files I sent earlier to ensure it isn't a .ma file issue? Could Maya 2018 be the issue?

Thanks for all the updates!

What is the license for the source?

Hi

This asset is very great for my specific needs. Can you tell me the license? No license file seems to be included in the repository.

Thanks for advance.

If recordLimitedFrames is false it only records the default (1000 frames)

I would expect it to continue recording until I hit the stop key.

If I change UnityAnimationRecorder.cs line 103 from:

if (frameIndex < recordFrames) {

to:

if ( recordLimitedFrames && frameIndex >= recordFrames) {

and swap the code in the if/else statement, then it will continue to record until I stop it manually.

Error when building with Unity 5.5

Hi,

first I'd like to let you know that this is fantastic!

However I'm having issues when Building with Unity 5.5. In editor.log, I get the following messagen:

Assets/3rd Party/Tools/Runtime Animation Recorder/UnityAnimSaver/UnityAnimationRecorder.cs(123,3): error CS0103: The name `AssetDatabase' does not exist in the current context

Thanks!

Getting this error when running on a Windows build

at AnimationCurveUtility.SetLinear (UnityEngine.AnimationCurve& curve) [0x00038] in C:\Users\Jesus\Documents\Unity Projects\formula_E_2\formula_E\Assets\Modules\AnimationGeneration\AnimationCurveUtility.cs:38

This is the line:
field.SetValue(boxed, GetNewTangentKeyMode((int)field.GetValue(boxed), TangentDirection.Left, TangentMode.Linear));

Huge files, long saves

So I'm trying to use this to clean up motion capture but 3 minutes alone is taking hours (at time of writing 26 minutes) to save. I want to use this for maybe 26 minute takes and edit it. Is there anything to do to fix this? So far this is the only solution that works exactly how we need.
We're willing to help fund a solution if needed as well, but any help is super appreciated.
To make it clear.
We're using motion capture and facial capture in play mode and saving the results.

Fbx exporter - Maya file naming

First of all thanks for the initiative and the project!!

Well, I am facing some problems with the fbx export.
For a simple file, it is taking over 1 hour to complete the process, and failing in the last stage.

I changed a bit your code, since it was hanging my Unity.
the cause of that was the while loops being executed (and called through the Update function)

If you have a sample of fbx would be helpful. I tested with some from Mixamo, after open them in Maya and export as ASC II.

Many Thanks,
Marcos

Ps. I should mention that I notice that for Maya files, whenever some Transform is named with special character such as : the process fail showing the error: Could not find part of "transformName"_dataX

Recording Humanoid rig

Hi,

Thanks for your asset, it has been a great help!

Question though: Is it possible to record a humanoid rig as a humanoid rig, to be used in Unity?
So far I've only managed to record it as a generic rig using the Unity Animation Recorder script, and converting those generic animations to humanoid has been problematic so far.

Best,
Maarten

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.