- Home /
Multiple animations problem.
I'm having this annoying problem with multiple animations. When my character moves, a certain animation plays. But I have a "booster" button that will play a "wings animation". So, when I move my character at normal speed, everything is fine but then, when I hold the "booster" button while moving, the "wings animation" starts and the "normal move animation" stops immediately. The character keeps moving forward but the moving animation is replaced by the wings animation. I've been trying to search for a way to solve this problem but all I get is people talking about animation layers, additive stuff or mixingtransforms but they all seem to assume that others are already aware of how those things work. The scripting reference didn't help and I can't seem to find any short tutorial on how to do this.
This is a fragment of my simple code:
function Update () {
if (shooting == false) {
var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
var z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
transform.Translate(x, 0, z);
}
if (Input.GetButton ("Booster")) {
boosted = true;
}
else
{
boosted = false;
}
if (Input.GetButtonDown ("Booster")) {
animation.Play("wingsanimation");
}
if (Input.GetButtonUp ("Booster")) {
animation.Play("wingsreturn");
}
if (boosted) {
speed = boostspeed;
}
else
{
speed = normalspeed;
}
if (shooting == false) {
if (Input.GetKeyDown (KeyCode.UpArrow)){
leanforward ();
}
function leanforward(){
leanforwardvar = true;
if (leanbackwardsvar == false){
animation.Play("leanforward");
}
}
Your answer
Follow this Question
Related Questions
how to make one script with different animations attached 2 Answers
Multiple animations in the same FBXfile? 9 Answers
Instantiates 2 or more gameObjects on ButtonUp. 1 Answer
Multiple animations for a character 1 Answer
easier animations 2 Answers