MissingComponentException: There is no 'Animation'

Hello there,

I am recieving a very strange error regarding a missing Component, the full error is as follows:

MissingComponentException: There is no ‘Animation’ attached to the “bear” game object, but a script is trying to access it.
You probably need to add a Animation to the game object “bear”. Or your script needs to check if the component is attached before using it.
UnityEngine.Animation.get_Item (System.String name) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/Animations.cs:545)
BearControlls.Start () (at Assets/BearControlls.cs:12)

Please note, this error does not stop the game from running, nor do I believe it to be correct. It is referring to this line of code:

animator.animation["backpedal"].normalizedTime = 1;

However, the line does as expected and causes no problems, aside from the insistent error.

The error means there is a point some time while running where the “bear” object does not have an animation on it. If it ends up working, that means it gets an animation at some point. Before that point, your code is trying to access the animation before it’s there so it shoots back the error. Try checking for the animation before you do anything to access it.

if (animator.animation["backpedal"]) {
    // animation stuff

The new Mechanim animation uses an animator component. The old (but good) animation uses an animation component. The line you have is using the old style, in a confusing way. The usual way is just animation["backpedal"]. Putting the extra animator in front make it look like it’s using the new Mechanim, but it isn’t.

It’s like writing animation.rigidbody.AddForce. It looks like an animation command, but it really says “find the animation. OK, now forget that and find the rigidbody next to it.” The same way, you could write light.renderer.transform and it’s just a confusing way to say transform.

The error says you don’t have a component labelled “Animation”. Errors (almost) never stop the game from running, so nothing new there. They do abort further lines in that script. If the line worked, it would reset the backpedal animation to the 1st frame (assuming it’s looping. normTime=1 is the last frame, which is the same as the 1st.)