Ejemplo n.º 1
0
        public void TraverseToDestination(float delta)
        {
            if (ReachedPosition(transform.position, moveLocation))
            {
                UpdateGridState();
                characterRigidBody.velocity = Vector3.zero;
                animationHandler.PlayTargetAnimation("CombatIdle");

                animationHandler.UpdateAnimatorValues(delta, 0f);
                transform.position = moveLocation;
                currentPathIndex   = 0;
                SetCurrentNavDict();

                stateManager.characterAction   = CharacterAction.None;
                stateManager.characterState    = CharacterState.Ready;
                characterRigidBody.constraints = RigidbodyConstraints.FreezeAll;
                //Debug.Log(characterStats.characterName + " Reached Destination");
            }

            else
            {
                AlchemyManager.Instance.ApplyCellToPlayer(GridManager.Instance.GetCellByIndex(path[currentPathIndex]).GetComponent <CellAlchemyState>(), characterStateManager);
                if ((ReachedPosition(transform.position, nextPos)))
                {
                    currentPathIndex++;
                    SetNextPos(path[currentPathIndex]);
                }

                Vector3 currentDirection = (nextPos - transform.position);
                currentDirection.y = 0f;
                currentDirection.Normalize();
                HandleRotation(delta, currentDirection);

                characterRigidBody.velocity = movementSpeed * currentDirection;
                RaycastHit hit;
                if (Physics.Raycast(transform.position, Vector3.down, out hit, (1 << 0)))
                {
                    if (hit.distance > .6 && transform.position.y > nextPos.y + .2f)
                    {
                        characterRigidBody.velocity += Vector3.down * 10f;
                    }
                }
                animationHandler.UpdateAnimatorValues(delta, 1f);
            }
        }
Ejemplo n.º 2
0
        public void ExcuteMovement(float delta)
        {
            moveDirection   = Vector3.zero;
            moveDirection   = cameraTransfrom.forward * inputHandler.MoveY + cameraTransfrom.right * inputHandler.MoveX;
            moveDirection.y = 0;
            moveDirection.Normalize();

            HandleRotation(delta, moveDirection);

            //Vector3 planarDirection = Vector3.ProjectOnPlane(moveDirection, normalVector);
            //characterRigidbody.velocity = planarDirection * movementSpeed;

            animationHandler.CheckAnimationState();
            animationHandler.UpdateAnimatorValues(delta);
        }