/// <summary>
        /// Character Roll.
        /// </summary>
        /// <param name="1">Forward.</param>
        /// <param name="2">Right.</param>
        /// <param name="3">Backward.</param>
        /// <param name="4">Left.</param>
        public IEnumerator _Roll(int roll)
        {
            rollNumber        = roll;
            currentState      = RPGCharacterStateFREE.Roll;
            rpgCharacterState = RPGCharacterStateFREE.Roll;
            if (rpgCharacterController.weapon == Weapon.RELAX)
            {
                rpgCharacterController.weapon = Weapon.UNARMED;
                animator.SetInteger("Weapon", 0);
            }
            animator.SetInteger("Action", rollNumber);
            animator.SetTrigger("RollTrigger");
            isRolling = true;
            rpgCharacterController.canAction = false;

            rollCollider.enabled   = true;
            normalCollider.enabled = false;

            yield return(new WaitForSeconds(rollduration));

            isRolling = false;

            rollCollider.enabled   = false;
            normalCollider.enabled = true;

            rpgCharacterController.canAction = true;
            currentState      = RPGCharacterStateFREE.Idle;
            rpgCharacterState = RPGCharacterStateFREE.Idle;
        }
Ejemplo n.º 2
0
 void Fall_SuperUpdate()
 {
     if (AcquiringGround())
     {
         currentVelocity   = Math3d.ProjectVectorOnPlane(superCharacterController.up, currentVelocity);
         currentState      = RPGCharacterStateFREE.Idle;
         rpgCharacterState = RPGCharacterStateFREE.Idle;
         return;
     }
     DoubleJump();
     currentVelocity -= superCharacterController.up * gravity * superCharacterController.deltaTime;
 }
Ejemplo n.º 3
0
 void DoubleJump()
 {
     if (!doublejumped)
     {
         canDoubleJump = true;
     }
     if (rpgCharacterInputController.inputJump && canDoubleJump && !doublejumped)
     {
         currentState      = RPGCharacterStateFREE.DoubleJump;
         rpgCharacterState = RPGCharacterStateFREE.DoubleJump;
     }
 }
 void Awake()
 {
     superCharacterController    = GetComponent <SuperCharacterController>();
     rpgCharacterController      = GetComponent <RPGCharacterControllerFREE>();
     rpgCharacterInputController = GetComponent <RPGCharacterInputControllerFREE>();
     navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();
     animator     = GetComponentInChildren <Animator>();
     rb           = GetComponent <Rigidbody>();
     if (rb != null)
     {
         //Set restraints on startup if using Rigidbody.
         rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
     //Set currentState to idle on startup.
     currentState      = RPGCharacterStateFREE.Idle;
     rpgCharacterState = RPGCharacterStateFREE.Idle;
 }
Ejemplo n.º 5
0
        void Jump_SuperUpdate()
        {
            Vector3 planarMoveDirection   = Math3d.ProjectVectorOnPlane(superCharacterController.up, currentVelocity);
            Vector3 verticalMoveDirection = currentVelocity - planarMoveDirection;

            if (Vector3.Angle(verticalMoveDirection, superCharacterController.up) > 90 && AcquiringGround())
            {
                currentVelocity   = planarMoveDirection;
                currentState      = RPGCharacterStateFREE.Idle;
                rpgCharacterState = RPGCharacterStateFREE.Idle;
                return;
            }
            planarMoveDirection    = Vector3.MoveTowards(planarMoveDirection, LocalMovement() * inAirSpeed, jumpAcceleration * superCharacterController.deltaTime);
            verticalMoveDirection -= superCharacterController.up * gravity * superCharacterController.deltaTime;
            currentVelocity        = planarMoveDirection + verticalMoveDirection;
            //Can double jump if starting to fall.
            if (currentVelocity.y < 0)
            {
                DoubleJump();
            }
        }
Ejemplo n.º 6
0
 void Move_SuperUpdate()
 {
     //If Jump.
     if (rpgCharacterInputController.allowedInput && rpgCharacterInputController.inputJump)
     {
         currentState      = RPGCharacterStateFREE.Jump;
         rpgCharacterState = RPGCharacterStateFREE.Jump;
         return;
     }
     if (!MaintainingGround())
     {
         currentState      = RPGCharacterStateFREE.Fall;
         rpgCharacterState = RPGCharacterStateFREE.Fall;
         return;
     }
     //Set speed determined by movement type.
     if (rpgCharacterInputController.HasMoveInput() && canMove)
     {
         //Keep strafing animations from playing.
         animator.SetFloat("Velocity X", 0F);
         //Strafing or Walking.
         if (rpgCharacterController.isStrafing)
         {
             currentVelocity = Vector3.MoveTowards(currentVelocity, LocalMovement() * walkSpeed, movementAcceleration * superCharacterController.deltaTime);
             if (rpgCharacterController.weapon != Weapon.RELAX)
             {
                 Strafing(rpgCharacterController.target.transform.position);
             }
             return;
         }
         //Run.
         currentVelocity = Vector3.MoveTowards(currentVelocity, LocalMovement() * runSpeed, movementAcceleration * superCharacterController.deltaTime);
     }
     else
     {
         currentState      = RPGCharacterStateFREE.Idle;
         rpgCharacterState = RPGCharacterStateFREE.Idle;
         return;
     }
 }
Ejemplo n.º 7
0
 //Run every frame we are in the idle state.
 void Idle_SuperUpdate()
 {
     //If Jump.
     if (rpgCharacterInputController.allowedInput && rpgCharacterInputController.inputJump)
     {
         currentState      = RPGCharacterStateFREE.Jump;
         rpgCharacterState = RPGCharacterStateFREE.Jump;
         return;
     }
     if (!MaintainingGround())
     {
         currentState      = RPGCharacterStateFREE.Fall;
         rpgCharacterState = RPGCharacterStateFREE.Fall;
         return;
     }
     if (rpgCharacterInputController.HasMoveInput() && canMove)
     {
         currentState      = RPGCharacterStateFREE.Move;
         rpgCharacterState = RPGCharacterStateFREE.Move;
         return;
     }
     //Apply friction to slow to a halt.
     currentVelocity = Vector3.MoveTowards(currentVelocity, Vector3.zero, groundFriction * superCharacterController.deltaTime);
 }