示例#1
0
        Quaternion SpringRotation(Quaternion current, Quaternion target)
        {
            var v_current = current.ToVector4();
            var v_target  = target.ToVector4();

            _vrotation  = ETween.Step(_vrotation, Vector4.zero, 1 + _rotationSpeed * 0.5f);
            _vrotation += (v_target - v_current) * (_rotationSpeed * 0.1f);
            return((v_current + _vrotation * Time.deltaTime).ToNormalizedQuaternion());
        }
示例#2
0
 public float Step()
 {
     if (config.interpolationType == Config.InterpolationType.Exponential)
     {
         currentValue = ETween.Step(
             currentValue, targetValue, config.interpolationSpeed);
     }
     else if (config.interpolationType == Config.InterpolationType.DampedSpring)
     {
         currentValue = DTween.Step(
             currentValue, targetValue, ref _velocity, config.interpolationSpeed);
     }
     else
     {
         currentValue = targetValue;
     }
     return(currentValue);
 }
示例#3
0
 void Update()
 {
     if (_interpolator == Interpolator.Exponential)
     {
         if (_positionSpeed > 0)
         {
             transform.position = ETween.Step(transform.position, target.position, _positionSpeed);
         }
         if (_rotationSpeed > 0)
         {
             transform.rotation = ETween.Step(transform.rotation, target.rotation, _rotationSpeed);
         }
     }
     else if (_interpolator == Interpolator.DampedSpring)
     {
         if (_positionSpeed > 0)
         {
             transform.position = DTween.Step(transform.position, target.position, ref _vposition, _positionSpeed);
         }
         if (_rotationSpeed > 0)
         {
             transform.rotation = DTween.Step(transform.rotation, target.rotation, ref _vrotation, _rotationSpeed);
         }
     }
     else
     {
         if (_positionSpeed > 0)
         {
             transform.position = SpringPosition(transform.position, target.position);
         }
         if (_rotationSpeed > 0)
         {
             transform.rotation = SpringRotation(transform.rotation, target.rotation);
         }
     }
 }
示例#4
0
 Vector3 SpringPosition(Vector3 current, Vector3 target)
 {
     _vposition  = ETween.Step(_vposition, Vector3.zero, 1 + _positionSpeed * 0.5f);
     _vposition += (target - current) * (_positionSpeed * 0.1f);
     return(current + _vposition * Time.deltaTime);
 }