void Update() { PlatformerController controller = GetComponent("PlatformerController") as PlatformerController; // We are not falling off the edge right now if (controller.GetHangTime() < hangTimeUntilFallingAnimation) { // Are we moving the character? if (controller.IsMoving()) { if (Input.GetButton("Fire2")) { GetComponent <Animation>().CrossFade("run"); } else { GetComponent <Animation>().CrossFade("walk"); } } // Go back to idle when not moving else { GetComponent <Animation>().CrossFade("idle", 0.5f); } } // When falling off an edge, after hangTimeUntilFallingAnimation we will fade towards the ledgeFall animation else { GetComponent <Animation>().CrossFade("ledgeFall"); } }