BCE0048: Type 'UnityEngine.Component' does not support slicing.

Hi!

After converting an older script from Unity 4 to 5 (ThirdPersonSimpleAnimation.js, I obtained it from Unity from somewhere, should be script everyone at least at some point had access to) I get a compiler error:

“BCE0048: Type ‘UnityEngine.Component’ does not support slicing.”

The line where I get this error is

animation["run"].normalizedSpeed = runSpeedScale;

I tried

(animation["run"] as AnimationClip).normalizedSpeed = runSpeedScale;

but that doesn’t work either, same message. Anyone an idea?

Just found it

(animation as Animation)["run"] as AnimationClip).normalizedSpeed = runSpeedScale;

and Unity 5 conversion process just after that made it to

((GetComponent.<Animation>() as Animation)["run"] as AnimationClip).normalizedSpeed = runSpeedScale;

BTW what also works is

GetComponent.<Animation>()["run"].normalizedSpeed = runSpeedScale;

:wink: