Unity Community


Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

  1. Location
    Warrington, UK
    Posts
    265
    not quite.

    now the player is constantly playing the walk animation when i press the key to walk. and not stopping when i release they key.

    what could be causing this?


  2. Location
    Warrington, UK
    Posts
    265
    I would really appreciate some help with this.


  3. Location
    Yesterday
    Posts
    664
    You're not stopping the walk animation when you release the key.

    Code:  
    1. if ( Input.GetKey( WalkKey ) ) {
    2.   // walk
    3. } else {
    4.   // Blend walk to zero influence over 0.2 seconds
    5.   animation.Blend("walk", 0, 0.2);
    6. }


  4. Location
    Warrington, UK
    Posts
    265
    Hi,

    ive ammended my script to this -

    Code:  
    1. animation["WALK"].layer=-1;
    2. animation["REVERSE"].layer=-1;
    3. animation["CROUCH"].layer=2;
    4. animation["IDLE"].layer=-3;
    5. var crouching: boolean;
    6.  
    7. function Update ()
    8. {
    9.    if (Input.GetAxis("Vertical") > 0.2){
    10.        animation.CrossFade ("WALK");
    11.        
    12.     }else{
    13.   // Blend walk to zero influence over 0.2 seconds
    14.   animation.Blend("WALK", 0, 0.2);
    15.   }
    16.    else if(Input.GetAxis("Vertical") < -0.2){
    17.        animation.CrossFade ("REVERSE");
    18.        // Play animation backwards when running backwards
    19.       animation["REVERSE"].speed = Mathf.Sign(Input.GetAxis("Vertical"));
    20. }
    21.   else{
    22.       animation.CrossFade ("IDLE");
    23.    }
    24.    
    25. if(Input.GetKey("c")){
    26.    animation.CrossFade ("CROUCH");
    27. }
    28. }

    but it is coming up with the errors -

    (16,4): BCE0044: expecting }, found 'else'.
    (28,1): BCE0044: expecting EOF, found '}'.
    not sure how to fix it

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •