Example #1
0
    Vector2 VelocityVectorDelta(GameObject parent, int framePlus)
    {
        SystemObject parentSystemObject = parent.GetComponent <SystemObject>();
        float        pull                = parentSystemObject.gravityPull;
        Vector2      parentPosition      = parentSystemObject.PositionAtTime(framePlus);
        Vector2      myPosition          = PositionAtTime(framePlus);
        float        invSquare           = 1.0f / (Vector2.Distance(parentPosition, myPosition) * Vector2.Distance(parentPosition, myPosition));
        Vector2      normalizedDirection = (parentPosition - myPosition).normalized;

        return(new Vector2(normalizedDirection.x * pull * invSquare, normalizedDirection.y * pull * invSquare));
    }