public void RestarGame() { SceneManager.LoadScene("SampleScene"); Objeto_1 OB1 = masa1.GetComponent <Objeto_1>(); OB1.s = false; Objeto_2 OB2 = masa2.GetComponent <Objeto_2>(); OB2.s = false; }
public void StarGame() { Objeto_1 OB1 = masa1.GetComponent <Objeto_1>(); OB1.s = true; Objeto_2 OB2 = masa2.GetComponent <Objeto_2>(); OB2.s = true; OB1.masa1 = float.Parse(txtM1.text); OB1.v1.x = float.Parse(txtV1.text); OB2.masa2 = float.Parse(txtM2.text); OB2.v2.x = float.Parse(txtV2.text); OB1.e = float.Parse(txtE.text); OB2.e = float.Parse(txtE.text); }
// Update is called once per frame void Update() { float t = Time.deltaTime; pos1 = gameObject.transform.position; Objeto_2 Script2 = Obj2.GetComponent <Objeto_2>(); Vector3 pos2 = Obj2.transform.position; float dist = (pos1 - pos2).magnitude; float distR = Script2.radio2 + radio1; if (dist < distR) { float masa2 = Script2.masa2; Vector3 v2 = Script2.v2; // v1.x = (((masa1 - e * masa2) * v1.x) + ((1 + e) * masa2 * v2.x)) / (masa1 + masa2); vp1.x = (masa1 - e * masa2) * v1.x / (masa1 + masa2) + ((1 + e) * masa2) * v2.x / (masa1 + masa2); //float num= (masa1 - e * masa2) *v1.x / (masa1 + masa2); } pos1 = pos1 + vp1 * t; gameObject.transform.position = pos1; }