예제 #1
0
        private static void ConfigureShellForce(GameObject gameObject)
        {
            Rigidbody rigidbody      = gameObject.GetComponent <Rigidbody>();
            Vector3   shellDirection = WarpSampler.Warp(WarpSampler.EWarpType.ECosineHemisphere);

            rigidbody.AddForce(shellDirection * 2f, ForceMode.Impulse);
            rigidbody.AddTorque(shellDirection);
        }
예제 #2
0
    protected override void OnUpdate()
    {
        float      time   = Time.time;
        GameObject Agents = GameObject.FindGameObjectWithTag("Agents");

        for (int i = 0; i < SpawnerComponents.Length; i++)
        {
            Spawner spawner = SpawnerComponents.Spawners[i];

            if (Mathf.Abs(time - spawner.TimeAtLastSpawn) > spawner.SecondsBetweenSpawns)
            {
                for (int j = 0; j < spawner.NumObjectsSpawned; j++)
                {
                    var spawnedObject = Object.Instantiate(spawner.SpawnedObject, spawner.transform);

                    spawnedObject.transform.parent = Agents.transform;

                    Vector3 pos = WarpSampler.Warp(WarpSampler.EWarpType.EUniformDisk);
                    pos.z = pos.y;
                    pos.y = 0;

                    spawnedObject.transform.position += spawner.SpawnDistance * pos;

                    var despawnables = Utilities.GetComponentsInHierarchy <Despawnable>(spawnedObject.transform);
                    foreach (var despawnable in despawnables)
                    {
                        if (despawnable != null)
                        {
                            despawnable.TimeAtSpawn = time;
                        }
                    }
                }

                spawner.TimeAtLastSpawn = time;
            }
        }
    }