Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

     // Are we jumping? (Initiated with jump button and not grounded yet)
     // Are we moving backwards (This locks the camera to not do a 180 degree spin)
     // When did the user start walking (Used for going into trot after a while)
     // the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
     void Awake()
     {
         moveDirection = transform.TransformDirection(Vector3.forward);

         _animation = GetComponent();
         if (!_animation)
             Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird.");

         /*
     public AnimationClip idleAnimation;
     public AnimationClip walkAnimation;
     public AnimationClip runAnimation;
     public AnimationClip jumpPoseAnimation;
         */
         if (!idleAnimation)
         {
             _animation = null;
             Debug.Log("No idle animation found. Turning off animations.");
         }
         if (!walkAnimation)
         {
             _animation = null;
             Debug.Log("No walk animation found. Turning off animations.");
         }
         if (!runAnimation)
         {
             _animation = null;
             Debug.Log("No run animation found. Turning off animations.");
         }
         if (!jumpPoseAnimation && canJump)
         {
             _animation = null;
             Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations.");
         }

     }