I need to create some walls on the fly and can add scripts to these walls usint AddComponent. I cannot understand how to add an animation to it. I have some animations that I made in the project folders and tried to add one like this.
newCurvedWall.AddComponent(Animation);
var anim : Animation = newCurvedWall.GetComponent(Animation);
anim.name = "LeftSpeed3";
anim.Play();
This does not hive errors but it also does not animate. These animations work if I drag onto a prefab or mesh in the Hierarchy, but I need to do it in script. How should I do this?