//jump kick in progress IEnumerator JumpKickInProgress() { animator.SetAnimatorBool("JumpKickActive", true); //a list of enemies that we have hit List <GameObject> enemieshit = new List <GameObject>(); //small delay so the animation has time to play yield return(new WaitForSeconds(.1f)); //check for hit while (playerState.currentState == UNITSTATE.JUMPKICK) { //draw a hitbox in front of the character to see which objects it collides with Vector3 boxPosition = transform.position + (Vector3.up * lastAttack.collHeight) + Vector3.right * ((int)currentDirection * lastAttack.collDistance); Vector3 boxSize = new Vector3(lastAttack.CollSize / 2, lastAttack.CollSize / 2, hitZRange / 2); Collider[] hitColliders = Physics.OverlapBox(boxPosition, boxSize, Quaternion.identity, HitLayerMask); //hit an enemy only once by adding it to the list of enemieshit foreach (Collider col in hitColliders) { if (!enemieshit.Contains(col.gameObject)) { enemieshit.Add(col.gameObject); //hit a damagable object IDamagable <DamageObject> damagableObject = col.GetComponent(typeof(IDamagable <DamageObject>)) as IDamagable <DamageObject>; if (damagableObject != null) { damagableObject.Hit(lastAttack); //camera Shake CamShake camShake = Camera.main.GetComponent <CamShake> (); if (camShake != null) { camShake.Shake(.1f); } } } } yield return(null); } }
//physics update void FixedUpdate() { //check if we are on the ground isGrounded = IsGrounded(); if (animator) { //set grounded animator.SetAnimatorBool("isGrounded", isGrounded); //check if we're falling animator.SetAnimatorBool("Falling", !isGrounded && rb.velocity.y < 0.1f && playerState.currentState != UNITSTATE.KNOCKDOWN); //update animator direction animator.currentDirection = currentDirection; } //check if the player is inside the camera view area playerInCameraView = PlayerInsideCamViewArea(); //update movement velocity if (updateVelocity && MovementStates.Contains(playerState.currentState)) { rb.velocity = fixedVelocity; updateVelocity = false; } //LETHAL FORCES - using Allow Air Control boolean if (AllowAirControl == true) { MoveAirborne(); } }