// Use this for initialization
    void Start()
    {
        Attractor = new Example_2_8_Attractor(CSizeX / 2, CSizeY / 2, 3, 0.2f);

        for (int i = 0; i < movers.Length; i++)
        {
            // TODO Fix NEW Warning when instatiating, make mono happy.
            movers[i]  = new Example_2_8_Mover(UnityEngine.Random.value * 4, 0f);
            spheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            spheres[i].transform.position =
                new Vector3(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);
        }
    }
Beispiel #2
0
    public Vector3 attract(Example_2_8_Mover m)
    {
        Vector3 force    = location - m.location;
        float   distance = force.magnitude;

        // TODO Constrain to some sueful Values; Look up how to
        //distance.constrain;
        distance = Mathf.Clamp(distance, 0.1f, 6f);

        force = force.normalized;
        float Strength = (G * mass * m.mass) / (distance * distance);

        force *= Strength;
        return(force);
    }