Problems with animation 'Legacy' on script c#

Hello everyone,

I’m new in Unity and actually I’m working in a project that I need to use a some animations to move some cube’s of my scene. The problem appear when I play the scene I have a script that in the function Start() I call the method animation.Play() to run the animation and the console show this message warning:

The AnimationClip ‘CubeMove’ used by the Animation component ‘Cube’ must be marked as Legacy.

And this error:

The animation state CubeMove could not be played because it couldn’t be found! Please attach an animation clip with the name 'CubeMove ’ or call this function only for existing animations.

But the animation is attached correctly in the component Animation.

I read in some post how to change the default to legacy but when I’m in Legacy mode the animation don’t work but I turn to change to default and work but show the error and warning.

If anyone can help me I would be very grateful.

What you need to do is go to the GameObject that your animation is attached to and go to the top under the category of Model and next is to hit the Select button after go to the “Rig” button and under the Animation Type change Generic to Legacy