示例#1
0
    private void PlayerInertia()
    {
        float deltaTime = Time.time - lastMotionTime;

        if (isAir)
        {
            // Apply total inertia.
            motor.ApplyFlatMotion(inertia);
        }
        else
        {
            if (deltaTime < maxInertiaApplyTime)
            {
                // Apply a decay inertia after stopped input, because there is friction resistance on the ground.
                motor.ApplyFlatMotion(Vector3.Lerp(inertia, Vector3.zero, deltaTime));
            }
            else
            {
                inertia = Vector3.zero;     // Clear inertia
            }
        }
    }