Ejemplo n.º 1
0
        void Start()
        {
            MovementAIRigidbody rb = obj.GetComponent <MovementAIRigidbody>();

            /* Manually set up the MovementAIRigidbody since the given obj can be a prefab */
            rb.SetUp();
            isObj3D = rb.is3D;

            /* Find the size of the map */
            float distAway = Camera.main.WorldToViewportPoint(Vector3.zero).z;

            bottomLeft = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distAway));
            Vector3 topRight = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, distAway));

            widthHeight = topRight - bottomLeft;

            /* Create the create the objects */
            for (int i = 0; i < numberOfObjects; i++)
            {
                /* Try to place the objects multiple times before giving up */
                for (int j = 0; j < 10; j++)
                {
                    if (TryToCreateObject())
                    {
                        break;
                    }
                }
            }
        }