コード例 #1
0
ファイル: MTRandomExample.cs プロジェクト: Dracir/semicolon
    private void MakeObjects()
    {
        // CENTER OF THE SPHERE: x = 0, y = 20, z = 0 I generate an object there
        GameObject _pivot = new GameObject();

        _pivot.transform.position = new Vector3(0, 0, 0);

        for (int i = 0; i < max_objects; i++)
        {
            // WE make a small sphere
            GameObject _sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            // WE SCALE THE SPHERE
            _sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            // TAKE A SCALED RANDOM POSITION
            Vector3 pos = ScalePosition(mrand.PointOnASphere());
            // WE set the sphere position
            _sphere.transform.position = pos;
            // WE give a tag to the sphere
            _sphere.tag = "Player";
            // remove collider
            Destroy(_sphere.transform.collider);
            _sphere.renderer.material.color = mrand.color();
            _sphere.transform.parent        = transform;
        }
    }