Пример #1
0
    private float Derive(float t, float duration, AnimationCurve curve)
    {
        switch (diffType)
        {
        case DifferenceType.Backward:
            return(DerivativeHelpers.BackwardDerivative(t, duration, curve.Evaluate));

        case DifferenceType.Forward:
            return(DerivativeHelpers.ForwardDerivative(t, duration, curve.Evaluate));

        case DifferenceType.Central:
            return(DerivativeHelpers.CentralDerivative(t, duration, curve.Evaluate));

        case DifferenceType.Symmetric:
        default:
            return(DerivativeHelpers.SymmetricDerivative(t, duration, curve.Evaluate));
        }
    }
Пример #2
0
    public void UpdateState()
    {
        float t = recoilTime - timeLeft;

        if (freezeGravity)
        {
            physics.velocity.Value = recoilForce * DerivativeHelpers.ForwardDerivative(t, recoilTime, recoilEase.Evaluate);
        }
        else
        {
            physics.velocity.X = recoilForce.x * DerivativeHelpers.ForwardDerivative(t, recoilTime, recoilEase.Evaluate);
        }
        physics.ParalyzedUpdate();

        if (timeLeft <= 0)
        {
            stateMachine.SetDefaultState();
        }
        else
        {
            timeLeft -= Time.deltaTime;
        }
    }