Esempio n. 1
0
    private void CreateSphere(GameObject hand)
    {
        CreateGravSphere();

        // create instance of gravsphere
        var sphere = Instantiate(gravsphere);

        sphere.tag = "gravity";
        // set location
        sphere.transform.position = hand.transform.position;
        sphere.transform.rotation = hand.transform.rotation;
        // set scale
        sphere.transform.localScale *= Random.Range(0.25f, 0.5f);
        // update list of spheres
        NewOrbits.UpdateSpheres();

        sphere.GetComponent <Rigidbody>().freezeRotation = true;

        var text3d       = new GameObject();
        var textMesh     = text3d.AddComponent <TextMesh>();
        var textRenderer = text3d.AddComponent <MeshRenderer>();

        textMesh.text = "Please work";



        textMesh.transform.SetParent(sphere.transform);
        textMesh.transform.localScale *= .5f;

        sphere.GetComponent <Renderer>().material = mats[Random.Range(0, mats.Length)];

        currentSphere = sphere;

        DestroyGravSphere();
    }
Esempio n. 2
0
    private void OnCollisionEnter(Collision collision)
    {
        var colliderObj = collision.collider.gameObject;

        if (colliderObj.tag != "gravity")
        {
            return;
        }
        Destroy(colliderObj);
        NewOrbits.UpdateSpheres();
    }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     GetComponent <Rigidbody>().velocity = transform.forward * 10;
     print(transform.forward);
     NewOrbits.UpdateSpheres();
 }