Ejemplo n.º 1
0
 public override bool GetControl(out DirectionVector direction)
 {
     if (_currentController == null)
     {
         direction = DirectionVector.Zero;
         return(false);
     }
     return(_currentController.GetControl(out direction));
 }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        DirectionVector direction;

        if (_controller.GetControl(out direction))
        {
            _isWalking    = true;
            _hasStopped   = false;
            _walkingSpeed = direction * _skillSet.Speed;
        }
        else
        {
            _walkingSpeed = Vector3.zero;
        }

        if (_rigidbody.velocity == Vector2.zero && _walkingSpeed == Vector3.zero)
        {
            return;
        }

        Vector3 currentSpeedVector = Vector3.Lerp(_rigidbody.velocity, _walkingSpeed, Acceleration);

        if (!_hasStopped)
        {
            _rigidbody.velocity = currentSpeedVector;

            _hasStopped = currentSpeedVector.Equals(Vector3.zero);

            if (_isWalking)
            {
                _isWalking = !_hasStopped;
            }
        }

        if (_isWalking)
        {
            WalkingAction.SafeInvoke(currentSpeedVector);
        }
    }