void CreateAndCaptureBody(Vector2 pos) { if (BodyPrefab) { var body = Instantiate(BodyPrefab) as Transform; body.gameObject.SetActive(true); var cbody = body.GetComponent <CelestialBody>(); if (_capturedBody) { Destroy(_capturedBody.gameObject); } if (cbody) { _capturedBody = cbody; var coll = body.GetComponentsInChildren <Collider2D>(); foreach (var c in coll) { c.enabled = false; } body.transform.position = pos; SetSizeFor(cbody, StartingMass); _capturedBody.FindAndSetMostProperAttractor(); _capturedBody.MakeOrbitCircle(); _capturedBody.enabled = false; } else { Destroy(body); return; } } }
void ShowCapturedOrbit() { if (_capturedBody) { _capturedBody.FindAndSetMostProperAttractor(); _capturedBody.CalculateNewOrbitData(); _capturedBody.DrawOrbit(); } }
void CreateAndCaptureBody(Vector2 pos) { if (BodyPrefab) { var body = Instantiate(BodyPrefab) as Transform; body.gameObject.SetActive(true); var cbody = body.GetComponent<CelestialBody>(); if (_capturedBody) { Destroy(_capturedBody.gameObject); } if (cbody) { _capturedBody = cbody; var coll = body.GetComponentsInChildren<Collider2D>(); foreach (var c in coll) { c.enabled = false; } body.transform.position = pos; SetSizeFor(cbody, StartingMass); _capturedBody.FindAndSetMostProperAttractor(); _capturedBody.MakeOrbitCircle(); _capturedBody.enabled = false; } else { Destroy(body); return; } } }