RuntimeAnimationController can not be accessed

Hi there,

I am having some problems with adding a RuntimeAnimationController to the Animator that I created dynamically.
The game object that the Animator is added to is also created at runtime.

var playerMohawk = GameObject.Find(“Mohawk”);
var thisAnimationObject = playerMohawk.AddComponent(“Animator”);
thisAnimationObject.RuntimeAnimationController = “Fly”;

But it will not allow me to add a RuntimeAnimationController, saying RuntimeAnimationController is not a member of Object. Any help?

It’s because AddComponent returns a Component object: AddComponent

You will need to cast what that object actually is:

var thisAnimationObject = playerMohawk.AddComponent("Animator") as Animator;