// Update is called once per frame void FixedUpdate() { Body.time += deltaTime; //Debug.Log(Body.time); //Vector2 rr = orbit.circularR(time);//orbit.r(Body.time); p = orbit.p / 60 / 60 / 24 / 365; a = orbit.a / units.AU; Vector2 rr = orbit.r(time); //float angle = ((time/60/60/24/365) / p)*360; //lol = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); //Vector2 rr = new Vector2(a*lol.x, a*lol.y); //ttt = a * lol.y; if (float.IsNaN(rr.x) || float.IsNaN(rr.y)) { rr = new Vector2(0, 0); } transform.localPosition = rr / units.AU * units.coordinateScale; //transform.position = new Vector2(0, 0); //transform.position = (rr);// *units.coordinateScale; //float radius_ = radius; //transform.localScale = new Vector3(radius_, radius_, radius_); //Debug.Log(transform.position.x); //Debug.Log(transform.position.y); }
public void viewGhosts(float time) { for (int i = 0; i < planets.Length; i++) { spheres[i].SetActive(true); Body b = planets[i].GetComponent <Body>(); Kepler orbit = b.orbit; spheres[i].transform.localScale = new Vector3(units.coordinateScale * b.radius / 60, units.coordinateScale * b.radius / 60, 1); spheres[i].transform.localPosition = orbit.r(time) / units.AU * units.coordinateScale; //Gizmos.color = new Color(0,255,0); //Gizmos.DrawSphere(orbit.r(time), units.coordinateScale*b.radius/60); //Gizmos.Draw } }
public void generate() { generateGhosts(); Kepler test = new Kepler(); test.fromEvA(units.AU, new Vector2(0, 0.0001f), units.G * (units.ME + units.ME * 333333)); Debug.Log(test.r(0).x / units.AU); //Generate the mainstar mainStar = new GameObject(); mainStar.AddComponent <Body>(); mainStar.GetComponent <Body>().generateStar(); //Generate planets planets = new GameObject[planetNum]; for (int i = 0; i < planetNum; i++) { planets[i] = new GameObject(); planets[i].AddComponent <Body>(); planets[i].transform.SetParent(mainStar.transform); Body component = planets[i].GetComponent <Body>(); component.generate(); component.parent = mainStar.GetComponent <Body>(); component.generateOrbit(systemSizelow, systemSizehigh); } //Generate Signals (events) signals = new Signal[signalNum]; for (int i = 0; i < signalNum; i++) { signals[i].generate(); } //Generate NPCs (enemies, shops, stations, one warp gate) //shop = new GameObject(); //shop.AddComponent<Shop>(); //Shop shopcomponent = shop.GetComponent<Shop>(); //shop.transform.localPosition = new Vector2(Random.Range(2f, 4f), Random.Range(-2f, -4f)); //ShopTextController stc = GameObject.Find("ShopPrices").GetComponent<ShopTextController>(); //stc.initThis(); }