Easy question about exposing variables -

Ok - so I’m trying to set up a simple, intuitive system for some AI…starting from scratch just to help myself get a better understanding of the code…

I’ve set this up:

var myState = "walkState";

var walkState : AnimationClip;
var attackState : AnimationClip;

function Update()
     {
     animation.Play(myState);
     }

The idea behind this is that as myState changes, it will show the corresponding clips, which I’ve set up in the inspector. However, I always get the error that animation clip walkState does not exist…

How can I do this so that inside animation.Play it calls the value of the variable for myState? I hope that made sense.

Thanks!

Check the list of animation component… you should drag the animation “walkState” to this list.

Yup - I’ve dragged the correct animations into the inspector into the right exposed variables. Still getting the same errors. I’ve tried configuring the order of things a little different too…tried this:

var walkState : AnimationClip; 
var attackState : AnimationClip; 


var myState = walkState; 

function Update() 
     { 
     animation.Play(myState); 
     }

Notice, this is without the quotes, and the variable myState SHOULD in theory take on the same EXACT value of whatever is dragged into the animation clip spot in th inspector…but then it tells me something along the lines of Animation.Clip is not a valid animation file. Any thoughts?