public void RefForce() { Bl = BallList.GetInstance(); PointMass = this.rigidbody.mass; PointPosition = V32Float(this.transform.position); float[] BallPosition = { 0, 0, 0 }; float[] BallForce = { 0, 0, 0 }; float BallMass = 0; foreach (Ball bl in Bl.balllist) { BallMass = bl.rigidbody.mass; BallPosition = V32Float(bl.transform.position); BallForce = GetGravity(PointMass, BallMass, PointPosition, BallPosition); for (int i = 0; i < 3; i++) { PointForce[i] += BallForce[i]; } } for (int i = 0; i < 3; i++) { PointForce [i] = PointForce [i] * 1f; } return; }
// Use this for initialization void Start() { float x, y, z, si, kg; float range = 1500; x = Random.Range(-range, range) * 1f; y = Random.Range(-range, range) * 1f; z = Random.Range(-range, range) * 1f; si = Random.Range(1, 3); kg = si * 5; this.transform.position = new Vector3(x, y, z); this.rigidbody.mass = kg; //this.transform.localScale.Set (si, si, si); BallList m; m = BallList.GetInstance(); m.balllist.Add(this); }