Exemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sphere"></param>
    /// <param name="energyDissipation" the ompact of the energy dissipation on the reflected velocity></param>
    void Choc(Sphere sphere, float energyDissipation = 0f)
    {
        if (!IsColliding(sphere))
        {
            return;
        }

        //Crazy formula
        if (IsSphereStatic(sphere))
        {
            sphere.transform.position = CorrectedPosition(sphere);
            sphere.ApplyForce(-sphere.mass * Physics.gravity);
        }
        else
        {
            InverseRelativeVelocity(sphere, Reflect(RelativeVelocity(sphere), energyDissipation));
        }
    }