Note
This package is currently in early preview and is subject to changes at any time.
Text2Motion's Unity integration client, can be use to make request to Text2Motion's API for generating Animation Clip on a given humanoid model.
Currently, the animation can only be generated for character with Mixamo rig name and structure. This package's sample provided an example Mixamo model that can be used for animation generation. Support for retargeting to other humanoid rig structure may be introduced in the future. Meanwhile, it is possible to take the animation generated from the example model, convert it to humanoid clip, and apply it to other non-Mixamo skeleton.
Text2Motion generates Animation Clip for Generic type FBX rig. This is because the output of Text2Motion API is transformation of bone position/rotation in individual keyframe. Humanoid Animation is based on how much the muscle is stretched instead of transformation/rotation of the bone. Also Humanoid Animation does not support keyframe. To make the generated generic animation clip more useful, you can follow the instruction to Converting Generic Clip to Humanoid Clip.
In order to use Text2Motion, you must sign up for an account and obtain the API Key via the developer portal.
- Go to https://developer.text2motion.ai/
- Click on Sign in on the upper right corner
- Click on LOGIN WITH SAML
- Choose either Continue with Google for Google SSO, or Sign Up with any email you own
- Click on your username on the upper right corner of the site
- Click on Apps
- Click on + NEW APP on the right side of the screen
- Put in an App Name, it could be
Unity Client
or whatever you want - Click Enable for Text2motion Free Tier
- Click Save
- You should now have an API Key. This will be needed later.
This package is only tested for Unity version 2022.3.4f1
. Other version have not been tested.
-
The options for adding packages appear.
Add package from git URL button -
Select Add package from git URL from the add menu. A text box and an Add button appear.
-
Add the
Text2Motion.CSharpClient
package firsthttps://github.com/text2motion/unity-integration.git?path=/Packages/ai.text2motion.unity.csharpclient
-
Add the
Text2Motion
packagehttps://github.com/text2motion/unity-integration.git?path=/Packages/ai.text2motion.unity.client
-
(Optional) From the Samples tab of Text2Motion Unity client package, import the Example MixamoRig model sample.
Note
All generated animations are licensed under CC-by-4.0
This instruction uses the Example MixamoRig model to create animation. You may try using your own model as long as it is are using MixamoRig.
- Create an empty GameObject in the Scene from the Hierarchy window
- Drag
Assets/Samples/Text2Motion/1.0.0/Example MixamoRig Model/Y Bot
under the GameObject created in the previous step
- With Y Bot selected in the Hierarchy window, click on Add Component in the Inspector window
- Select Component > Scripts > Text2Motion > Animation Clip Generator
- Fill in the key you obtained from Obtaining the API Key here
- Drag
mixamorig:Hips
under Y Bot into Root Bone for Animation input settings
- Click Initialize T-Pose from FBX asset
- Click Load
- After that, you should be able to generate animation by providing a prompt
We recommend using Visual Studio Code for developing this package. To get started, make sure you follow the Unity installation step first. Then with the Unity project open:
- Go to Edit > Preferences... > External Tools
- Change External Script Editor to
Visual Studio Code
and click Regenerate project files
After that, set up Visual Studio code
From here you should be able to open up the repository in Visual Studio Code and start developing. You can hit F5
to start debugger and set breakpoint to test the Package.
The Animation Clip Generator script has 4 tabs.
- New tab let you create new animation clips
- Clip Name must be unique
- If left empty, one will be generated
- Advanced Parameters:
- You can disable root motion by unchecking Apply Root Motion so the animation play in place without moving the character away from the starting location.
- Since the generated animation clip is generic type, changing Apply Root Motion setting on the Animator will not work.
- Disable root motion using the option under Animation output settings and regenerate a new animation
- Alternatively, if you Converting Generic Clip to Humanoid Clip, Apply Root Motion setting on the Animator will work.
- Position offset can be use to adjust the character's position in the generated animation. For example, the current sample we have sinks into the ground so we move it up by 0.37 in the Y axis.
- You can disable root motion by unchecking Apply Root Motion so the animation play in place without moving the character away from the starting location.
- Clip Name must be unique
- Replace tab is essentially the same as New, but instead of creating new Clip, you select an existing clip to overrides
- Load tab let you load animation from a list of previous Text2Motion API request, in case the clips were deleted.
- Option tab let you reset the script and also point to additional setting under the Project Settings. Note that you must click Reload Settings button under the Option tab to refresh setting cache if the Project Settings was modified.
Text2Motion generates generic animation clips, which means you will be able to modify keyframe directly. This may be useful for trimming generated animation where the start and end of the animation isn't doing much, or just for snipping part of the animation.
It may be useful to convert the Generic Animation Clip generated from Text2Motion to Humanoid Clip. For example, once it is converted to Humanoid Clip, we can apply this animation on any other humanoid rig type that may not be MixamoRig structure.
To do this, get the FBX Exporter package first.
Once you have the package:
- Select the GameObject with the Text2Motion animation clips.
- Right click the GameObject and select Export to FBX
- For Options > Include select Model(s) + Animation.
- Click Export
- Select the exported fbx file in Project window
- In the Inspector window, go to the Rig tab
- Change the Animation Type from Generic to Humanoid
- Hit Apply
From here, you'd be able to duplicate the animation clip in the FBX file and use it elsewhere for other humanoid rig.