Transition from Legacy to Generic/Humanoid

Hi I’ve been using the Legacy animation system because its simple and straightforward, but now I’ve reached a point where I want to transfer the animations used from one character to another, apparently the only way to do that is either retype them in inspector with the Legacy system (not gona do that cuz my main character has over 200 animations, one time was painful enough), or I herd u can share animations across different gameobjects if they have either generic or humanoid.

So i’ve set my main character to Humaniod, created an animation controller, dragged and dropped the animation in the controller, added an Animatior to the gameobject, dragged and dropped the controller on it, but now I can’t play the animations, in legacy in order to play an animation you just type animation.play(“NameOfAnimation”);
same for speed, wrapmode etc, what the key word for playing animation in the newer mode?

Looking at online tutorials they control animations in the Animator or in code by creating variables for each animation or state (don’t really understand it).

Basically I dont really care about transition smoothy between animations in legacy animation.blend and crossfade did the job. I just want to play an animation the most straightforward way using Animator.

P.S. I had tried an alternative method, this new character that I want to share animations with has a biped with bones named the same as the main character, same number of bones used too, so with the legacy system I simply dragged the animations from the main character onto the new one, and it works, but after a little while the frame rate drops to single digits, can anyone tell me why and if it can be fixed? if not then plz help me transition from legacy to generic.

Edit: I found this on the site, it seems the most straightforward way

var anim : Animator;
var jumpHash : int = Animator.StringToHash(“Jump”);

anim = GetComponent(“Animator”);
anim.SetTrigger (jumpHash);

But when I use it, it doesnt play, and I get a message saying “Parameter ‘Hash -255461497’ does not exist.”. Am I on the right lines here? if so then wht do I make of this message? Also do I have to make transitions in the animator for this to work?

It will be well worth your time to take about 30 minutes to skim through the Mecanim tutorials: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn

It will make everything so much clearer for you. Nothing is going to make sense until you have a basic understanding of how Mecanim works, since it’s very different from the Legacy system. But once you’ve taken a few minutes to skim through the tutorials above, you may wonder why you didn’t switch over to Mecanim sooner. :slight_smile:

That said, in your example, you need to define a Parameter named Jump. Then create a transition from, say, an Idle state to your Jump state. The condition on the transition should be Jump==true. And then add a transition back to Idle with the condition ExitTime.

There’s another way to do this. I’m hesitant to suggest it because it’s not really the right way in Mecanim. But you can use anim.Play(state) or anim.CrossFade(state). Don’t do this, though. Skim the tutorials and set up a simple animation state machine instead.

Hi,

there is no side effect by using Animator.Play or Animator.CrossFade at runtime. Transition from one state to another one either with a transition made in the editor or with a dynamic transition created with Animator.Play/CrossFade has the same cost.

Sonny

I didn’t mean to imply that there are problems with Animator.Play or Animator.CrossFade. They work great for their purposes. But using them simply to avoid learning how to build state machines and parameter-based transitions might not be the best approach, since one would miss out on some of the major advantages of Mecanim.

I agree, one of the main advantages is that you can organize and build your controller in the editor and avoid all the logic that you need to write with script to animate your object.