// Use this for initialization void Start() { Attractor = new Example_2_7_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_7_Mover(UnityEngine.Random.value * 4, (UnityEngine.Random.value - 0.5f) * 20); spheres[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); spheres[i].transform.position = new Vector3(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value); } }
public Vector3 attract(Example_2_7_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); }