Beispiel #1
0
    private void DoSpawnObject(ObjectSpawnInfo info)
    {
        var spawnedObject = Instantiate(info.prefab) as GameObject;

        spawnedObject.transform.position      = info.coords;
        spawnedObject.transform.localScale   *= UnityEngine.Random.Range(1f - scaleVariance, 1f + scaleVariance);
        spawnedObject.transform.localRotation = Utility.GetRandomRotation();
        ObjectGenerated?.Invoke(spawnedObject);
        maintainedObjects.Add(spawnedObject);
    }
    void GenerateCanisterPair()
    {
        var yOffset     = UnityEngine.Random.Range(-1f, 1f) * transversalOffset;
        var xOffset     = UnityEngine.Random.Range(-1f, 1f) * transversalOffset;
        var worldCoords = solipsist.transform.position + new Vector3(xOffset, yOffset, distanceOfSpawn);

        //var offset = solipsist.transform.localRotation * Vector3.right * 20f; // spawn radius

        //for (var i = 0; i < 2; i++) {
        var firstCanisterInstance = Instantiate(createWhat);

        firstCanisterInstance.transform.position = worldCoords;
        maintainedObjects.Add(firstCanisterInstance);
        ObjectGenerated?.Invoke(firstCanisterInstance);
        //}
    }
Beispiel #3
0
    private void SpawnCanisters(float atZ)
    {
        Debug.Log($"Spawning canisters at z {atZ}");
        var yOffset     = UnityEngine.Random.Range(-1f, 1f) * canisterSpawnRadius;
        var xOffset     = UnityEngine.Random.Range(-1f, 1f) * canisterSpawnRadius;
        var worldCoords = solipsist.transform.position + new Vector3(xOffset, yOffset, atZ);

        var offset = solipsist.transform.localRotation * Vector3.right * canisterSpawnRadius;

        for (var i = 0; i < 2; i++)
        {
            var firstCanisterInstance = Instantiate(canisterPrefab);
            firstCanisterInstance.transform.position = worldCoords + offset * i;
            maintainedObjects.Add(firstCanisterInstance);
            ObjectGenerated?.Invoke(firstCanisterInstance);
        }
    }
    public void GenerateAll()
    {
        int numObjects = Mathf.FloorToInt(cubeDimensions.x * cubeDimensions.y * cubeDimensions.z * objectDensity / 1000000f);

        for (var i = 0; i < numObjects; i++)
        {
            // spawn object
            var coords = Vector3.Scale(Utility.GetRandomVector(), extents);
            coords = transform.TransformPoint(coords);
            var @object = Instantiate(prefab, coords, Utility.GetRandomRotation());
            var fo      = @object.GetComponent <FudgedInfiniteObject>();
            fo.Initialize(this);
            maintainedObjects.Add(fo);
            ObjectGenerated?.Invoke(@object);
        }
        Debug.Log($"Infinite object field spawned {maintainedObjects.Count} objects");
    }