//Put any code in here you want to run AFTER the state's update function.  This is run regardless of what state you're in.
 private void LateUpdate()
 {
     //If alive and is moving, set animator.
     if (!rpgCharacterController.isDead && canMove)
     {
         if (currentVelocity.magnitude > 0)
         {
             isMoving = true;
             animator.SetBool("Moving", true);
             //Swimming.
             if (rpgCharacterState == RPGCharacterState.Swim)
             {
                 animator.SetFloat("Velocity Z", transform.InverseTransformDirection(currentVelocity).z);
             }
             //Not swimming.
             else
             {
                 animator.SetFloat("Velocity Z", currentVelocity.magnitude);
             }
         }
         else
         {
             isMoving = false;
             animator.SetBool("Moving", false);
         }
         //Sprinting.
         if (isSprinting)
         {
             animator.SetBool("Sprint", true);
         }
         else
         {
             animator.SetBool("Sprint", false);
         }
     }
     //Aiming.
     if (rpgCharacterController.isAiming)
     {
         Aiming();
     }
     else
     {
         if (!rpgCharacterController.isStrafing)
         {
             if (rpgCharacterInputController.HasMoveInput() && canMove)
             {
                 RotateTowardsMovementDir();
             }
         }
         else
         {
             Strafing(rpgCharacterController.target.transform.position);
         }
     }
 }
예제 #2
0
 //Put any code in here you want to run AFTER the state's update function.  This is run regardless of what state you're in.
 protected override void LateGlobalSuperUpdate()
 {
     //Move the player by our velocity every frame.
     transform.position += currentVelocity * superCharacterController.deltaTime;
     //If using Navmesh nagivation, update values.
     if (useMeshNav && navMeshAgent != null)
     {
         if (navMeshAgent.velocity.sqrMagnitude > 0)
         {
             animator.SetBool("Moving", true);
             animator.SetFloat("Velocity Z", navMeshAgent.velocity.magnitude);
         }
     }
     //If alive and is moving, set animator.
     else if (!rpgCharacterController.isDead && canMove)
     {
         if (currentVelocity.magnitude > 0 && rpgCharacterInputController.HasMoveInput())
         {
             isMoving = true;
             animator.SetBool("Moving", true);
             animator.SetFloat("Velocity Z", currentVelocity.magnitude);
         }
         else
         {
             isMoving = false;
             animator.SetBool("Moving", false);
         }
     }
     if (!rpgCharacterController.isStrafing)
     {
         if (rpgCharacterInputController.HasMoveInput() && canMove)
         {
             RotateTowardsMovementDir();
         }
     }
     else
     {
         Strafing(rpgCharacterController.target.transform.position);
     }
 }
예제 #3
0
        void RunningAttack(int attackSide)
        {
//			Debug.Log("RunningAttack");
            //If armed and moving, running attacks.
            if ((weapon == Weapon.ARMED || weapon == Weapon.ARMEDSHIELD) && rpgCharacterInputController.HasMoveInput())
            {
                if (attackSide == 1 && rpgCharacterWeaponController.HasLeftWeapon())
                {
                    animator.SetInteger("Action", 1);
                    animator.SetTrigger("AttackTrigger");
                }
                if (attackSide == 2 && rpgCharacterWeaponController.HasRightWeapon())
                {
                    animator.SetInteger("Action", 4);
                    animator.SetTrigger("AttackTrigger");
                }
                if (attackSide == 3 && rpgCharacterWeaponController.HasDualWeapons())
                {
                    animator.SetInteger("Action", 1);
                    animator.SetTrigger("AttackDualTrigger");
                }
            }
        }
예제 #4
0
 //Put any code in here you want to run AFTER the state's update function.  This is run regardless of what state you're in.
 protected override void LateGlobalSuperUpdate()
 {
     //Move the player by our velocity every frame.
     transform.position += currentVelocity * superCharacterController.deltaTime;
     //If using Navmesh nagivation, update values.
     if (navMeshAgent != null)
     {
         if (useMeshNav)
         {
             if (navMeshAgent.velocity.sqrMagnitude > 0)
             {
                 animator.SetBool("Moving", true);
                 animator.SetFloat("Velocity Z", navMeshAgent.velocity.magnitude);
             }
             else
             {
                 animator.SetFloat("Velocity Z", 0);
             }
         }
     }
     //If alive and is moving, set animator.
     if (!useMeshNav && !rpgCharacterController.isDead && canMove)
     {
         if (currentVelocity.magnitude > 0 && rpgCharacterInputController.HasMoveInput())
         {
             isMoving = true;
             animator.SetBool("Moving", true);
             //Swimming.
             if (rpgCharacterState == RPGCharacterState.Swim)
             {
                 animator.SetFloat("Velocity Z", transform.InverseTransformDirection(currentVelocity).z);
             }
             //Not swimming.
             else
             {
                 animator.SetFloat("Velocity Z", currentVelocity.magnitude);
             }
         }
         else
         {
             isMoving = false;
             animator.SetBool("Moving", false);
         }
         //Sprinting.
         if (isSprinting)
         {
             animator.SetBool("Sprint", true);
         }
         else
         {
             animator.SetBool("Sprint", false);
         }
     }
     //Aiming.
     if (rpgCharacterController.isAiming)
     {
         Aiming();
     }
     else
     {
         //Rotate towards movement direction.
         if (!rpgCharacterController.isStrafing)
         {
             if (rpgCharacterInputController.HasMoveInput() && canMove)
             {
                 RotateTowardsMovementDir();
             }
         }
         //Otherwise rotate towards Target. (strafing)
         else
         {
             Strafing(rpgCharacterController.target.transform.position);
         }
     }
 }