IEnumerator ReplaceBall() { yield return(new WaitForSeconds(5)); /* while (this.transform.parent != null) * { * yield return new WaitForSeconds(5); * }*/ this.GetComponent <MeshRenderer>().enabled = false; yield return(new WaitForSeconds(.5f)); this.GetComponent <Rigidbody>().velocity = Vector3.zero; this.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; GameObject sPlanet = this.GetComponent <BallGrab>().getStartingPlanet(); GameObject ePlanet = this.GetComponent <BallGrab>().getTransitionedPlanet(); Gravity2.TransitionPlanetGravity(ePlanet, sPlanet, this.gameObject); print("resetting gravity"); this.gameObject.transform.position = startPos; this.GetComponent <MeshRenderer>().enabled = true; // ScoringMechanic.S.IncrementScore(); }
// Start is called before the first frame update void OnTriggerEnter(Collider coll) { if (coll.gameObject.tag == "Ball") //transitions gravitational attraction to this planet if ball crosses trigger { //print("transition hit"); Gravity2.TransitionPlanetGravity(coll.gameObject.GetComponent <BallGrab>().getStartingPlanet(), planet.gameObject, coll.gameObject); } }
public void InstantRespawn() { this.GetComponent <MeshRenderer>().enabled = false; this.GetComponent <Rigidbody>().velocity = Vector3.zero; this.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; GameObject sPlanet = this.GetComponent <BallGrab>().getStartingPlanet(); GameObject ePlanet = this.GetComponent <BallGrab>().getTransitionedPlanet(); Gravity2.TransitionPlanetGravity(ePlanet, sPlanet, this.gameObject); print("resetting gravity"); this.gameObject.transform.position = startPos; this.GetComponent <MeshRenderer>().enabled = true; }
void Start() { planet = this.transform.parent.GetComponent <Gravity2>(); }
// Use this for initialization void Start() { localGrav = this.GetComponentInChildren <Gravity2>(); StartCoroutine(DisableCollider()); //the gravitational transition is still a bit weird, disable trigger after a while }