Search Unity

Attack animation

Discussion in 'Animation' started by welpie21, Dec 23, 2014.

  1. welpie21

    welpie21

    Joined:
    Dec 23, 2014
    Posts:
    49
    Hello i want to know is how can i make that my axe is swinging.
    first is that i already animated the axe.
    but how can i do that in game.

    i make this java script. but i dont know its right its not giving errors.
    Code (JavaScript):
    1. // Use this for initialization
    2. function Start () {
    3. }
    4.  
    5. // Update is called once per frame
    6. function Update () {
    7.     {
    8.     // Links muis klik
    9.     if(Input.GetMouseButtonDown(0))
    10.             Debug.Log("Pressed Left Click.");
    11.     animation.Play("Attack", PlayMode.StopAll);
    12.     }
    13.    
    14.     {
    15.     // Rechts muis klik
    16.     if(Input.GetMouseButtonDown(1))
    17.             Debug.Log("Pressed Right Click.");
    18.     animation.Play("ZoomIn", PlayMode.StopAll);
    19.     }
    20.    
    21.     {
    22.     if(Input.GetKeyDown("w"))
    23.     animation.Play("Walk", PlayMode.StopAll);
    24.     }
    25.    
    26.     {
    27.     if(Input.GetKeyDown("shift") && ("w"))
    28.     animation.Play("Run", PlayMode.StopAll);
    29.     }
    30.    
    31.     {
    32.     if(Input.GetKeyDown("c"))
    33.     animation.Play("Crouch", PlayMode.StopAll);
    34.     }
    35.  
    36.      {
    37.     if(Input.GetKeyDown("e"))
    38.     animation.Play("Pickup", PlayMode.StopAll);
    39.     }
    40.    
    41.     {
    42.     if(Input.GetKeyDown("d"))
    43.     animation.Play("WalkRight", PlayMode.StopAll);
    44.     }
    45.    
    46.     {
    47.     if(Input.GetKeyDown("a"))
    48.     animation.Play("walkLeft", PlayMode.StopAll);
    49.     }
    50.    
    51.     {
    52.     if(Input.GetKeyDown("r"))
    53.     animation.Play("Reload", PlayMode.StopAll);
    54.     }
    55.    
    56.     {
    57.     if(Input.GetKeyDown("ctrl"))
    58.     animation.Play("Phrone", PlayMode.StopAll);
    59.     }
    60.    
    61.     {
    62.     if(Input.GetKeyDown("s"))
    63.     animation.Play("ReverseWalk", PlayMode.StopAll);
    64.     }
    65. }
    66.  
    so if you can help me. thx
     

    Attached Files:

  2. welpie21

    welpie21

    Joined:
    Dec 23, 2014
    Posts:
    49
    sorry for some dutch words. and the other animations is still in progress.
     
  3. Ezio1302

    Ezio1302

    Joined:
    Apr 25, 2014
    Posts:
    5
    This would have been better to post on Unity Answers. If this is still a problem, all of your if statements are formatted incorrectly. Instead of:
    1. {
    2. if(Input.GetKeyDown("your key"))
    3. //Your code
    4. }
    It should be:
    1. if(Input.GetKeyDown("your key"))
    2. {
    3. //Your code
    4. }