Example #1
0
    //TODO will caching getter values change performance?

    public Vector3 GetCurrentForceVector(CustomForce parentForce, ForceObject objectAppliedTo)
    {
        Vector3 projection = Vector3.Project(objectAppliedTo.GetRecentNetAcceleration(), NormalVector);

        if (projection.magnitude < (projection - NormalVector).magnitude)
        {
            return(Vector3.zero);
        }
        return(-projection * NormalForceMultiplier);
    }
Example #2
0
    private void CalculateApplySpeed(ForceObject forceObject, Vector3 normal)
    {
        if (Vector3.Angle(sourceMassObject.GetRecentNetSpeed(), normal) > 90)
        {
            return;
        }

        Vector3 projection = Vector3.Project(sourceMassObject.GetRecentNetSpeed() + sourceMassObject.GetRecentNetAcceleration(), normal); //TODO this bad. better if after physics

        Vector3 speedApplication = projection * massMultiplier / (isPure ? 1 : forceObject.GetMass()) * speedTransferranceMultipler;

        forceObject.DirectAdjustAddSpeed(speedApplication - lastSpeedApplied[forceObject]);

        lastSpeedApplied[forceObject] = speedApplication; //APPLY AFTER SYSTEM? If not work.
    }