I'm trying to use a script to play Animation Clips that I have loaded into variables. So far not much luck: Code (CSharp): using UnityEngine; using System.Collections; using System.Collections.Generic; public class AnimationControl : MonoBehaviour { public bool SelectState; public AnimationClip CurrentAnimation; public AnimationClip Normal; public AnimationClip Selected; public AnimationClip Destroyed; public AnimationClip Timed; public string CurrAnimToStr; void ToString() { CurrAnimToStr = CurrentAnimation.name; } void TimedVersion(){ } void GetSelectTrue(){ PieceScore triggers = GetComponent<PieceScore>(); SelectState = triggers.isSelected; if(SelectState == true) { CurrentAnimation = Selected; } } void AnimationController() { GetSelectTrue(); } // Use this for initialization void Start () { CurrentAnimation = Normal; } // Update is called once per frame void Update () { AnimationController(); animation.Play("CurrentAnimation"); } } Yeah its incomplete. It won't play the animation clip. Is the name of the clip stored as a String? How do I access it and get it to play from the stored variables?
Ok I'm changing this up a bit. I've setup an animator with 4 states and 4 motions. I want to rewrite this script to change the motion attached to each state on the fly. Lets say one state is "Normal" and has a motion attached. The next state is "Selected" and has a motion attached. I want to be able to swap the motions out from another script. However I can't find anything in the manual that allows me to select a state from the animator component or the motion attached to that state. I see: hasRootMotion applyRootMotion and: GetNextAnimationClipState GetNextAnimatorStateInto and current ones too So how would I actually grab a specific state within the animation and apply a variable as a motion?