- Home /
Add curves to .anim files from Mixamo Animation Store?
Hi guys,
I've downloaded some animations from Mixamo's Animation Store for use in my game, and some of the animations are variants of jump animations where the character's collider size must be adjusted during the jump. There is a basic Jump animation that is part of a .fbx file that I got from an example (not from Mixamo) which features a curve (as per this YouTube tutorial) for adjusting the collider size during the jump. However, I can't figure out how to add curves to the jump animations that I bought from Mixamo (which are .anim files), nor can I figure out how to add those .anim files to a .fbx file in order to add curves in the FBX inspector window. Is there any way to add curves to .anim files, and/or to add .anim files purchased from the Mixamo store to .fbx files in order to add curves to them? Thanks in advance, this is important because if a jump animation is played without it having a curve for resizing the collider, the collider just shrinks to half its size during the jump with no other control.
MachCUBED
Answer by TonyLi · Aug 01, 2013 at 02:56 PM
Unity doesn't yet support Mecanim animation curves on .anim files. You can only add them to .fbx files. You can use something like the Event System for Mecanim to trigger events that will change the collider, though.
I could do that, or I could simply add curves directly to my script and have the script modify the size of my collider over time. Here's my proposed code:
/// <summary>
/// Curves for collider and gravity management during jumps
/// </summary>
public AnimationCurve colliderHeight;
public AnimationCurve gravityWeight;
public AnimationCurve accelerationUp;
What I have below is my current code that manipulates the size of the collider based on animation curves. It needs to be modified to get its curve information from the above code.
...
else if(currentBaseState.nameHash == jumpState) // if we are in the jumping state...
{
if(!animator.IsInTransition(0)) // ..and not still in transition..
{
// ..set the collider height to a float curve in the clip called ColliderHeight
//Old code for animation curves built into anims
col.height = animator.GetFloat("ColliderHeight");
// Add a velocity boost when jumping
//Old code for animation curves built into anims
rigidbody.AddForce(Vector3.up * animator.GetFloat("AccelerationUp"));
// reset the Jump bool so we can jump again, and so that the state does not loop
animator.SetBool("Jump", false);
}
// Raycast down from the center of the character..
Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(ray, out hitInfo))
{
// ..if distance to the ground is more than 0.25, use $$anonymous$$atch Target
if (hitInfo.distance > 0.25f)
{
// $$anonymous$$atchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.
// Here we're telling the Root of the character to only be influenced on the Y axis ($$anonymous$$atchTargetWeight$$anonymous$$ask) and only occur between 0.35 and 1.35
// of the timeline of our animation clip
animator.$$anonymous$$atchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new $$anonymous$$atchTargetWeight$$anonymous$$ask(new Vector3(0, 1, 0), 0), 0.35f, 1.35f);
}
}
}
...
How should I derive my data from the script's own curve data?
AnimationCurve is a legacy animation curve for a legacy animation clip. It's different from a $$anonymous$$ecanim (Pro only) animation curve.
Can you get the FBX version from $$anonymous$$ixamo? At least for the animation(s) that need curves?
Somehow, I just can't seem to figure out how to get FBX animations from the in-Unity store that I've downloaded.
Unfortunately, you can't. But if you paid for the animation from the in-Unity store (versus the Unlimited version of the store), $$anonymous$$ixamo may credit you to get the same animation from their website in FBX format. Just send them an email. They have really good customer support.
Your answer
Follow this Question
Related Questions
How can I convert .anim files to .fbx files? 1 Answer
Curves in .anim files? 2 Answers
Animation files 1 Answer
Everything works in Maximo but exporting it to Unity will give me problems.. 0 Answers
Modify Mixamo humanoid animation 2 Answers