Beispiel #1
0
        private void PlayerMove()
        {
            // 방향키 안눌렀을 때
            if (((horizontalMove < Mathf.Epsilon) && (horizontalMove > -Mathf.Epsilon)) &&
                ((verticalMove < Mathf.Epsilon) && (verticalMove > -Mathf.Epsilon)))
            {
                velocity = 0.0f;
                moveVector.Set(horizontalMove, -0.0f, verticalMove);
                moveVector = moveVector.normalized;
                transform.Translate(moveVector);

                animator.SetInteger("State", 0);
                return;
            }

            // WASD/방향키 move
            if (state == PlayerState.walk)
            {
                if (velocity < walkMaxVel)
                {
                    velocity = velocity + walkAcc * Time.deltaTime;
                    velocity = Mathf.Clamp(velocity, 0.0f, walkMaxVel);
                }
                else
                {
                    velocity = velocity - runAcc * Time.deltaTime;
                    velocity = Mathf.Clamp(velocity, 0.0f, runMaxVel);
                }

                animator.SetInteger("State", 1);
            }
            else if (state == PlayerState.run)
            {
                velocity = velocity + runAcc * Time.deltaTime;
                velocity = Mathf.Clamp(velocity, 0.0f, runMaxVel);

                statusController.DecreaseSp(1000 * Time.deltaTime);

                tutorialController.isPlayerRun = true;

                animator.SetInteger("State", 2);
            }

            moveVector.Set(horizontalMove, -0.0f, verticalMove);
            moveVector = moveVector.normalized * velocity * Time.deltaTime;
            transform.Translate(moveVector);
            //_rigidbody.MovePosition(transform.position + moveVector);
            //_rigidbody.AddForce(moveVector);

            tutorialController.isPlayerMove = true;
        }