I'm following a tutorial to create an infinite race game (Temple Run style), the tutorial is old and the classes etc changed in Unity 5, so I could not reproduce the code, it's done to control and execute the animations of the character .. If the Start key was pressed it starts the walking animation, but the skip does not give because I would have to use WrapMode to give priority to it, but that is not working .. So by logic I tried like this ( I tried other ways, but the game crashes, like that).
#pragma strict
var anim : Animator;
function Start () {
anim = GetComponent.<Animator>();
}
function Update () {
/* if(Controle.Start == false){
anim.SetBool ("ande", false) ;
}*/
if(Controle.Start == true){
anim.SetBool ("ande", true); // Verifica se deu start e inicia a anim de andar
}
/*if(Controle.cair == true){
anim.SetBool ("morra", true); // essa era a de morrer mas está com o mesmo problema
}*/
Teste();
}
/* Tentei arrumar criando essa função que enquanto o espaço tiver pressionado ele desativa
o start e logo após ele executa a animação de pulo, mas não deu, tentei outros jeitos usando
while mas sem sucesso */
function Teste(){
if(Input.GetKey("space")){
while(Input.GetKey("space")){
Controle.Start = false;
}
anim.SetBool ("pule", true);
}
}
How do I fix this? I already tried everything, WrapMode would be with GetComponent., but the animations did not work with Animation.