Ejemplo n.º 1
0
    public static void AttractPixelsTowardsRB(MakePixels mp, Rigidbody attractTo, bool useRad, float force)
    {
        float rmax = mp._attractRadius * mp._pixelSize;

        foreach (Rigidbody rb in mp._pixels)
        {
            if (rb == attractTo)
            {
                continue;
            }

            Vector3 offset = (attractTo.transform.position - rb.transform.position);
            float   l2     = offset.sqrMagnitude;
            if ((useRad && l2 > rmax * rmax))
            {
                continue;
            }
            if (l2 <= Mathf.Epsilon)
            {
                continue;
            }

            l2      = Mathf.Sqrt(l2);
            offset /= l2;

            rb.AddForce(offset * force, ForceMode.Impulse);
            attractTo.AddForce(-offset * force, ForceMode.Impulse);
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     _makePixels    = GameObject.Find("PlayerCharacter").GetComponent <MakePixels>();
     _pixelsBeenHit = new List <GameObject>();
 }
Ejemplo n.º 3
0
    private void Start()
    {
        _mp = FindObjectOfType <MakePixels>();

        _camera = FindObjectOfType <Camera>().GetComponent <FixedCameraScroll>();
    }