O'Reilly logo

Unity 3 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating CrossFade animation

In this section, we will apply and create the animation clip to our character and make it suitable for each action such as idle, walk, run, jump, and fall animation.

Engage Thrusters

We will start with creating the Awake() function:

  1. Go to the Awake() function to set up warpMode of the animation, and type the following highlighted script:
    //Using Awake to set up parameters before Initialize
    public function Awake() : void {
      controller = GetComponent(CharacterController);
      b_isRun = false;
      b_isBackward = false;
      b_isJumping = false;
      f_moveSpeed = speed;
      c_collisionFlags = CollisionFlags.CollidedBelow;
      
      //Set warpMode for each animation clip
      animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampForever;
     animation[fallPoseAnimation.name].wrapMode ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required