Пример #1
0
        /*****************************
        *          Methods          *
        *****************************/
        public void MovePlayer(InputAction.CallbackContext context)
        {
            var value = context.ReadValue <float>();

            if (value > 0)
            {
                _moveDirection = 1;

                var currentScale = characterContainer.transform.localScale;
                characterContainer.transform.localScale = new Vector3(Math.Abs(currentScale.x), currentScale.y, currentScale.z);

                if (updateAnimator)
                {
                    animator.MoveState(Math.Abs(transform.position.x));
                }
            }
            else if (value < 0)
            {
                _moveDirection = -1;

                var currentScale = transform.localScale;
                characterContainer.transform.localScale = new Vector3(-1 * Math.Abs(currentScale.x), currentScale.y, currentScale.z);

                if (updateAnimator)
                {
                    animator.MoveState(Math.Abs(transform.position.x));
                }
            }
        }
Пример #2
0
        /*****************************
        *          Update           *
        *****************************/

        /*****************************
        *          Methods          *
        *****************************/
        public void Move(InputAction.CallbackContext context)
        {
            _inputVelocity = context.ReadValue <float>();

            var velocityX = physicsObject.isRunning ? _inputVelocity * runSpeed : _inputVelocity * normalSpeed;

            physicsObject.targetVelocity.x = velocityX;

            var transform1 = transform;
            var localScale = transform1.localScale;

            localScale           *= new Vector2(((_inputVelocity * localScale.x) < 0) ? -1 : 1, 1);
            transform1.localScale = localScale;
            if (updateAnimator)
            {
                animator.MoveState(Math.Abs(velocityX));
            }
        }