Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Animation application problem

Discussion in 'Animation' started by Arpatos, Nov 17, 2013.

  1. Arpatos

    Arpatos

    Joined:
    Nov 17, 2013
    Posts:
    1
    Hey,

    I have 3 animations (walk, run and jump).
    But when I save my script, it told me that error:
    Assets/Standard Assets/Scripts/Camera Scripts/Movecharacter.js(51,42): BCE0019: 'animation' is not a member of 'Object'.

    Here is the Movecharacter script :

    Code (csharp):
    1. #pragma strict
    2.    
    3.     var speed:float;
    4.     var speedRun:float;
    5.     var speedRotate:float;
    6.     var gravity:float;
    7.     var jumpspeed:float;
    8.    
    9.     private var controller:CharacterController;
    10.     private var moveDirection:Vector3;
    11.     private var deltaTime:float;
    12.     private var characterContent;
    13.     private var runAnim:boolean;
    14.     private var run:boolean;
    15.    
    16.    
    17.     function Start () {
    18.         controller = GetComponent("CharacterController");
    19.         characterContent = transform.Find("samuzai");
    20.     }
    21.    
    22.     function Update () {
    23.        
    24.         deltaTime = Time.deltaTime;
    25.         runAnim = false;
    26.        
    27.         if(controller.isGrounded){
    28.    
    29.             if(Input.GetKey(KeyCode.LeftShift)){
    30.                 moveDirection = Vector3(0,0,Input.GetAxis("Vertical") * speedRun);
    31.                 runAnim = true;
    32.             }
    33.             else{
    34.                 moveDirection = Vector3(0,0,Input.GetAxis("Vertical") * speed);
    35.             }
    36.            
    37.             if(Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow)){  
    38.                 if(!runAnim){
    39.                     characterContent.animation.CrossFade("walk", 0.2);
    40.                 }
    41.                 else{
    42.                     characterContent.animation.CrossFade("run", 0.2);
    43.                 }
    44.             }
    45.             else{
    46.                     characterContent.animation.CrossFade("idle", 0.2);
    47.             }
    48.             if(Input.GetKey(KeyCode.Space)){
    49.            
    50.                 moveDirection.y = jumpspeed;
    51.                 characterContent.animation.CrossFade("jump", 0.2);
    52.            
    53.             }
    54.         }
    55.            
    56.            
    57.             moveDirection = transform.TransformDirection(moveDirection);
    58.            
    59.             transform.Rotate(Vector3(0,Input.GetAxis("Horizontal") * speedRotate * deltaTime,0));
    60.            
    61.             moveDirection.y -= gravity * deltaTime;
    62.            
    63.             controller.Move(moveDirection * deltaTime);
    64.     }

    Thanks :)