Пример #1
0
    private void CreateSphere()
    {
        GameObject spawnPoint = spawnPointManager.NearestSpawnpoint(transform.position);

        if (spawnPoint)
        {
            GameObject newBall = (GameObject)Instantiate(prefabBall,
                                                         spawnPoint.transform.position, Quaternion.identity);
            Destroy(newBall, destroyAfterDelay);
        }
    }
    /*----------------------------------------------------------
     * retrieve a randome / nearby spawnpoint from the spawn point manager
     * can create clone of prefab object (and store reference to new object in 'newBall')
     * set it to be Destroyed after 'destroyAfterDelay' seconds
     */
    private void CreateSphere()
    {
        GameObject spawnPoint = spawnPointManager.NearestSpawnpoint(transform.position);

        // only try to instantiate prefab if spawnpoint is NOT null
        if (spawnPoint)
        {
            GameObject newBall = (GameObject)Instantiate(prefabBall, spawnPoint.transform.position, Quaternion.identity);
            Destroy(newBall, timeBetweenSpawns / 2);
        }
    }