Search Unity

animations don´t get completed... (video with explanation)

Discussion in 'Animation' started by U7Games, Nov 15, 2013.

  1. U7Games

    U7Games

    Joined:
    May 21, 2011
    Posts:
    943
    hi

    !!

    I have a problem with animations, it looks well imported from blender, but in play mode it won't to work correctly...

    here is a video with explanation..

    Excuse me please take a look..



    and here is my code for the player:

    Code (csharp):
    1.  
    2. #pragma strict
    3. #pragma implicit
    4.  
    5. private var direccion : Vector3 = Vector3.zero;
    6. private var anim : Animation;
    7. private var combo : BoxCollider;
    8.  
    9. private var puedeSaltar : boolean = true;
    10.  
    11.  
    12.  
    13. var activado : boolean = true;
    14.  
    15. private var polvo : ParticleEmitter;
    16.  
    17.  
    18. function Awake () {
    19. anim = GetComponent(Animation);
    20. polvo = GameObject.Find("Player/polvo").GetComponent(ParticleEmitter);
    21. combo = GameObject.FindWithTag("combo").GetComponent(BoxCollider);
    22.  
    23. }
    24.  
    25.  
    26. function Update() {
    27. var controlador : CharacterController = GetComponent(CharacterController);
    28.  
    29. if (activado){
    30.  
    31.     if (controlador.isGrounded) {
    32.         direccion = Vector3(0, 0, Input.GetAxis("Vertical"));
    33.         direccion = transform.TransformDirection(direccion);
    34.         direccion *= 12;
    35.    
    36.         transform.Rotate(Vector3(0, Input.GetAxis("Horizontal") * 4, 0));
    37.    
    38.    
    39.         if (controlador.velocity.magnitude > 0){   
    40.             anim.CrossFade("anim_runAdventure");
    41.             //camaraAnim.CrossFade("anim_aumentarFOV");
    42.             polvo.emit = true;
    43.             }
    44.        
    45.         else{
    46.             anim.CrossFade("anim_idleAdventure");
    47.             //camaraAnim.CrossFade("anim_normalizarFOV");
    48.             polvo.emit = false;
    49.             }
    50.        
    51.      Golpe();
    52.      Patada();
    53.            
    54.      Salto();
    55.                
    56.         }
    57.  
    58.  
    59.     direccion.y -= 70 * Time.deltaTime;
    60.        
    61.     controlador.Move(direccion * Time.deltaTime);
    62.     }
    63.    
    64. else{
    65.     anim.CrossFade("anim_idleAdventure");  
    66.     polvo.emit = false;
    67.     }
    68.  
    69. }
    70.  
    71.  
    72. function Salto () {
    73. if (Input.GetButton ("Jump")  puedeSaltar){
    74.     puedeSaltar = false;
    75.     anim.Play("anim_playerJump");
    76.     direccion.y = 35;
    77.     yield WaitForSeconds(anim["anim_playerJump"].length + 1f);
    78.     puedeSaltar = true;
    79.     }
    80. }
    81.  
    82. function Golpe () {
    83. if (Input.GetKey ("q")  !js_playerData.golpeando){
    84.     js_playerData.golpeando = true;
    85.     activado = false;
    86.     anim.Play("anim_combo1");
    87.     //combo.isTrigger = false;
    88.     yield WaitForSeconds(anim["anim_combo1"].length - .2f);
    89.    
    90.     for (var a : int = 0; a <= 100; a++){
    91.         if (Input.GetKey ("q")){   
    92.             anim.Play("anim_patada1");
    93.             yield WaitForSeconds(anim["anim_patada1"].length);
    94.             break;
    95.             }
    96.        
    97.         }
    98.    
    99.    
    100.     //combo.isTrigger = true;
    101.     js_playerData.golpeando = false;
    102.     activado = true;
    103.     }
    104. }
    105.  
    106. function Patada () {
    107. if (Input.GetKey ("w")  !js_playerData.golpeando){
    108.     js_playerData.golpeando = true;
    109.     activado = false;
    110.     anim.Play("anim_patada1");
    111.     yield WaitForSeconds(anim["anim_patada1"].length);
    112.     js_playerData.golpeando = false;
    113.     activado = true;
    114.     }
    115. }
    116.  

    As you can see, this is very important, because the punch has a collider, if punch is not straight there will be no an easy collision with enemy...


    What could it be??...
    Thank you !!!
     
    Last edited: Nov 15, 2013
  2. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
    you had to show what is happening in the Animator window (Mecanim), while the combo animtion is getting played. Is the combo animation clip playing untill the end? Your transition, back to the Idle might be happening too soon, or be too long and start transitting to the Idle, before the combo clip ends. Have you checked if everything is okay with the Clip in the Animator window?
     
  3. U7Games

    U7Games

    Joined:
    May 21, 2011
    Posts:
    943
    Hi Instruct9r, thanks for answering...

    there is no information on Animator Window... what do i must to select to activate information on this Window?
     
  4. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
    Open the animator window and select your character in the scene (The character that have the Animator component). Then you will see the clips for your character in the Animator window. Is your punch on a different layer?