- Home /
Which code do I use to change animation of Spine? (Noob..)
I've imported an animation from Spine and want the animation to change according to the actions of my player. I'll use an if statement for it but I don't know how to change the state of the animation from within the code.. I'm a real noob so go easy on me..(=
Thanks in advance!
Answer by william9518 · Nov 17, 2013 at 07:47 PM
I am assuming you are using a FPS kit because this is a script. So basically, you would make another script and in the update function or another function, you would write: Since that script is in C# I will provide my answer in C#.
void Update(){
if(characterIsWalking){whereEverTheSkeletonAnimationScriptIs.GetComponent<SkeletonAnimation>().Animation = enumNameOfTheAnimationThingy.walk;} else { whereEverTheSkeletonAnimationScriptIs.GetComponent<SkeletonAnimation>().Animation = enumNameOfTheAnimationThingy.jump;
}
}
Sorry for the HORRIBLE formatting as Unity does not like super long lines.
Im having a problem with this... specifically this part:
enumNameOfTheAnimationThingy.walk
Where exactly are you talking about? This is what I currently have.
if (Input.Get$$anonymous$$ey ("space")) { this.GetComponent().animation = Animation.jump;
Your answer
Follow this Question
Related Questions
Very silly and simple javascript question 1 Answer
Rotate to a set degree then reverse and repeat 1 Answer
Animation stoping!! 1 Answer
How to make a button that opens and closes a tab? 1 Answer
Dice Value 1 Answer