Exemple #1
0
 //
 protected virtual void Update()
 {
     //
     if (IsPlayerControlled() && input.PressFire())
     {
         StartJumpAnticipation();
     }
     if (getUpCounter > 0)
     {
         getUpCounter -= Time.deltaTime;
         //
         // *****************  LIFT ARMS OFF OF THE GROUND SLOWLY WHEN GETTING UP ************
         //
         foreach (CharacterMaintainHeight h in otherMaintainHeight)
         {
             h.desiredHeight = Mathf.Lerp(h.desiredHeight, 0.2f, Time.deltaTime * 3);
         }
     }
     if (jumpAnticipation)
     {
         //***********************************  CROUCHING BEFORE JUMP **********************
         //
         jumpCounter += Time.deltaTime;
         if (jumpCounter >= jumpDelay)
         {
             Jump();
         }
     }
     else if (inAir)
     {
         //***********************************  AIR BORNE **********************
         //
         jumpCounter += Time.deltaTime;
         if (jumpCounter >= airTimeDelay)
         {
             GetUpFromJump();
         }
         //
     }
     else
     {
         //***********************************  STANDING ON GROUND **********************
         //
         inputDirection = Vector3.zero;
         if (IsPlayerControlled())
         {
             if (input.HoldRight())
             {
                 inputDirection += Vector3.right;
             }
             if (input.HoldLeft())
             {
                 inputDirection += Vector3.left;
             }
             if (input.HoldUp())
             {
                 inputDirection += Vector3.forward;
             }
             if (input.HoldDown())
             {
                 inputDirection += Vector3.back;
             }
         }
         else
         {
             inputDirection = OutOfPossessionDirection();
         }
         if (inputDirection != Vector3.zero)
         {
             // *** MOVE BASED ON INPUT DIRECTION ****
             //
             inputDirection.Normalize();
             //
             currentFacing   = chestBody.transform.forward;
             currentFacing.y = 0;
             currentFacing.Normalize();
             //
             if (!legs.walking)
             {
                 legs.StartWalking();
             }
             //
             faceDirection.facingDirection = inputDirection;
             //
             if (input.HoldDash())
             {
                 chestBody.AddForce(chestBody.transform.forward * sprintForce);
             }
         }
         else
         {
             // *** STAND STILL WHEN ZERO INPUT ****
             //
             faceDirection.facingDirection = currentFacing;
             //
             if (legs.walking)
             {
                 legs.StopWalking();
             }
         }
     }
 }