//--------------------runner------------------------
        public void FixedTick(float d)
        {
            delta              = d;
            isBlocking         = false;
            rigid.constraints &= ~RigidbodyConstraints.FreezePositionY;

            //-----------------Handle Actions and Interactions and States--------------------

            //_________Attack (inAction)_______
            if (onGround == true)
            {
                usingItem = anim.GetBool("interacting");
                anim.SetBool("spellcasting", isSpellCasting);
                if (inventoryManager.rightHandWeapon != null)
                {
                    inventoryManager.rightHandWeapon.weaponModel.SetActive(!usingItem);
                }
                if (inventoryManager.curConsumable != null)
                {
                    if (inventoryManager.curConsumable.itemModel != null)
                    {
                        inventoryManager.curConsumable.itemModel.SetActive(usingItem);
                    }
                }



                if (isBlocking == false && isSpellCasting == false)
                {
                    enableIK = false;
                }

                if (inAction)
                { //"inAction" evaluation.
                    anim.applyRootMotion = true;
                    _actionDelay        += delta;
                    if (_actionDelay > 0.3f)
                    { // Make Room: if the action is more than 0.3s, reset it again to make room for another action to take place.
                        inAction     = false;
                        _actionDelay = 0;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            //_____Start of States______
            onEmpty = anim.GetBool("OnEmpty");
            //canMove = anim.GetBool("canMove");

            if (onEmpty)
            {
                canMove   = true;
                canAttack = true;
            }

            if (canRotate)
            {
                HandleRotation();
            }

            if (!onEmpty && !canMove && !canAttack) //Stop updating when all of the state managing variable is false (most likely the character is inAction)
            {
                return;
            }

            if (canMove && !onEmpty)
            {
                if (moveAmount > 0)
                {
                    anim.CrossFade("Empty Override", 0.1f);
                    onEmpty = true;
                }
            }

            if (canAttack)
            {
                DetectAction();
            }
            if (canMove)
            {
                DetectItemAction();
            }

            // turn off RootMotion after the animation is played.
            anim.applyRootMotion = false;

            if (inventoryManager.blockCollider.gameObject.activeSelf)
            {
                isInvincible = true;
            }

            //_____End of States_____

            // --------Handle movement and physics-------
            //physics
            if (moveAmount > 0 || !onGround)
            {
                rigid.drag = 0;
            }
            else
            {
                rigid.drag = 4;
            }

            //movement
            if (usingItem || isSpellCasting)
            {
                run        = false;
                moveAmount = Mathf.Clamp(moveAmount, 0, 0.5f);
            }

            if (onGround && canMove)
            {
                rigid.velocity = moveDir * (moveSpeed * moveAmount);
            }

            if (run)
            {
                moveSpeed = 5.5f;
                lockOn    = false;
            }
            else
            {
                moveSpeed = 3f;
            }

            HandleRotation();

            // ------Handle movement's animations------
            anim.SetBool("lockon", lockOn);
            if (lockOn == false)
            {
                HandleMovementAnimation();
            }
            else
            {
                HandleLockOnAnimations(moveDir);
            }

            //anim.SetBool("blocking", isBlocking);
            anim.SetBool("isLeft", isLeftHand);

            //________________________
            a_hook.useIK = enableIK;
            HandleBlocking();

            if (isSpellCasting)
            {
                HandleSpellCasting();
                return;
            }
            //_________________________

            //Rolls (inAction)
            a_hook.CloseRoll();
            if (onGround == true)
            {
                HandleRolls();
            }

            //_________________________
            if (lockOn == false)
            {
                lockOnTarget = null;
            }
            if (lockOnTarget != null)
            {
                lockOnTarget.isLockOn = true;
            }
        }
Beispiel #2
0
        public void FixedTick(float d)
        {
            delta      = d;
            rigid.drag = (moveAmount > 0 || !onGround) ? 0 : 4;

            usingItem = anim.GetBool("interacting");

            DetectItemAction();
            DetectAction();
            inventoryManager.curWeapon.weaponModel.SetActive(!usingItem);

            if (inAction)
            {
                anim.applyRootMotion = true;

                _actionDelay += delta;
                if (_actionDelay > 0.6f)
                {
                    inAction     = false;
                    _actionDelay = 0;
                }
                else
                {
                    return;
                }
            }

            canMove = anim.GetBool("canMove");

            if (!canMove)
            {
                return;
            }

//			a_hook.rm_muliplier = 1;
            a_hook.CloseRoll();
            HangleRolls();

            anim.applyRootMotion = false;

            float targetSpeed = moveSpeed;

            if (usingItem)
            {
                isRunning  = false;
                moveAmount = Mathf.Clamp(moveAmount, 0, 0.45f);
            }

            if (isRunning)
            {
                targetSpeed = runSpeed;
            }

            if (onGround)
            {
                rigid.velocity = moveDir * (targetSpeed * moveAmount);
            }

            if (isRunning)
            {
                lockOn = false;
            }

            Vector3 targetDir = (!lockOn) ? moveDir : (lockOnTransform != null) ? lockOnTransform.position - transform.position : moveDir;

            targetDir.y = 0;
            if (targetDir == Vector3.zero)
            {
                targetDir = transform.forward;
            }
            Quaternion tr             = Quaternion.LookRotation(targetDir);
            Quaternion targetRotation = Quaternion.Slerp(transform.rotation, tr, delta * moveAmount * rotateSpeed);

            transform.rotation = targetRotation;

            anim.SetBool("lockOn", lockOn);

            if (!lockOn)
            {
                HandleMovementAnimations();
            }
            else
            {
                HandleLockOnAnimations(moveDir);
            }
        }
Beispiel #3
0
        public void FixedTick(float d)
        {
            delta = d;

            DetectAction();

            if (inAction)
            {
                anim.applyRootMotion = true;

                _actionDelay += delta;
                if (_actionDelay > 0.3f)
                {
                    inAction     = false;
                    _actionDelay = 0;
                }
                else
                {
                    return;
                }
            }

            canMove = anim.GetBool("canMove");

            if (!canMove)
            {
                return;
            }

            // a_hook.rm_multi = 1;
            a_hook.CloseRoll();
            HandleRolls();

            anim.applyRootMotion = false;

            rigid.drag = (moveAmount > 0 || onGround == false) ? 0 : 4;

            float targetSpeed = moveSpeed;

            if (run)
            {
                targetSpeed = runSpeed;
            }

            if (onGround)
            {
                rigid.velocity = moveDir * (targetSpeed * moveAmount);
            }

            if (run)
            {
                lockOn = false;
            }

            Vector3 targetDir = (lockOn == false) ?
                                moveDir
                :
                                (lockOnTransform != null) ?
                                lockOnTransform.transform.position - transform.position
                    :
                                moveDir;

            targetDir.y = 0;
            if (targetDir == Vector3.zero)
            {
                targetDir = transform.forward;
            }
            Quaternion tr             = Quaternion.LookRotation(targetDir);
            Quaternion targetRotation = Quaternion.Slerp(transform.rotation, tr, delta * moveAmount * rotateSpeed);

            transform.rotation = targetRotation;

            anim.SetBool("lockon", lockOn);

            if (lockOn == false)
            {
                HandleMovementAnimations();
            }
            else
            {
                HandleLockOnAnimations(moveDir);
            }
        }
Beispiel #4
0
        public void FixedTick(float delta)
        {
            this.delta = delta;

            usingItem = animator.GetBool("interacting");

            DetectItemAction();
            DetectAction();
            inventoryManager.rightHandWeapon.weaponModel.SetActive(!usingItem);


            if (inAction)
            {
                animator.applyRootMotion = true;

                _actionDelay += delta;
                if (_actionDelay > 0.3f)
                {
                    inAction     = false;
                    _actionDelay = 0;
                }
                else
                {
                    return;
                }
            }

            canMove = animator.GetBool("can_move");

            if (!canMove)
            {
                return;
            }

            // animatorHook.rootMotionMultiplier = 1;
            animatorHook.CloseRoll();
            HandleRolls();

            animator.applyRootMotion = false;

            rigidBody.drag = (moveAmount > 0 || !onGround) ? 0 : 4;

            float targetSpeed = moveSpeed;

            if (usingItem)
            {
                run        = false;
                moveAmount = Mathf.Clamp(moveAmount, 0, 0.45f);
            }
            if (run)
            {
                targetSpeed = runSpeed;
            }

            if (onGround)
            {
                rigidBody.velocity = moveDirection * (targetSpeed * moveAmount);
            }

            if (run)
            {
                lockOn = false;
            }

            Vector3 targetDirection = (!lockOn) ? moveDirection : (lockOnTransform) ? lockOnTransform.transform.position - transform.position : moveDirection;

            targetDirection.y = 0;

            if (targetDirection == Vector3.zero)
            {
                targetDirection = transform.forward;
            }

            Quaternion rotation       = Quaternion.LookRotation(targetDirection);
            Quaternion targetRotation = Quaternion.Slerp(transform.rotation, rotation, delta * moveAmount * rotateSpeed);

            transform.rotation = targetRotation;

            animator.SetBool("lockon", lockOn);

            if (!lockOn)
            {
                HandleMovementAnimations();
            }
            else
            {
                HandleLockOnAnimations(moveDirection);
            }
        }
        public void FixedTick(float d)
        {
            delta = d;

            isBlocking = false;
            usingItem  = anim.GetBool(StaticStrings.interacting);
            DetectAction();
            DetectItemAction();
            inventoryManager.rightHandWeapon.weaponModel.SetActive(!usingItem);

            anim.SetBool(StaticStrings.blocking, isBlocking);
            anim.SetBool(StaticStrings.isLeft, isLeftHand);

            if (inAction)
            {
                anim.applyRootMotion = true;

                _actionDelay += delta;

                if (_actionDelay > .3f)
                {
                    inAction     = false;
                    _actionDelay = 0;
                }
                else
                {
                    return;
                }
            }

            canMove = anim.GetBool(StaticStrings.canMove);

            if (!canMove)
            {
                return;
            }

            //a_hook.rm_multi = 1f;
            a_hook.CloseRoll();
            HandleRolls();

            anim.applyRootMotion = false;
            rigid.drag           = (moveAmount > 0 || onGround == false) ? 0f : 4f;

            float targetSpeed = moveSpeed;

            if (usingItem)
            {
                run        = false;
                moveAmount = Mathf.Clamp(moveAmount, 0, .45f);
            }

            if (run)
            {
                targetSpeed = runSpeed;
            }

            if (onGround)
            {
                rigid.velocity = moveDir * (targetSpeed * moveAmount);
            }

            if (run)
            {
                lockOn = false;
            }

            Vector3 targetDir = (lockOn == false) ? moveDir :
                                (lockOnTransform != null) ? lockOnTransform.position - transform.position : moveDir;

            targetDir.y = 0;
            if (targetDir == Vector3.zero)
            {
                targetDir = transform.forward;
            }
            Quaternion tr             = Quaternion.LookRotation(targetDir);
            Quaternion targetRotation = Quaternion.Slerp(transform.rotation, tr, delta * moveAmount * rotateSpeed);

            transform.rotation = targetRotation;

            anim.SetBool(StaticStrings.lockon, lockOn);

            if (!lockOn)
            {
                HandleMovementAnimations();
            }
            else
            {
                HandleLockOnAnimations(moveDir);
            }
        }