Exemplo n.º 1
0
    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();
    }
Exemplo n.º 2
0
 // 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);
     }
 }
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
 void Start()
 {
     planet = this.transform.parent.GetComponent <Gravity2>();
 }
Exemplo n.º 5
0
 // 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
 }