Beispiel #1
0
        void Update()
        {
            if (Input.GetKeyDown(keyToSpawn))
            {
                // Activate/Respawn/Move one game object each time 'Spawn' is called
                GameObject spawned = pool.Spawn(
                    randomEssentials.GetRandomVector3(-5, 5),     // Position
                    Quaternion.identity,                          // Rotation
                    randomEssentials.GetRandomVector3(0.5f, 1.5f) // Scale
                    );

                // Set a random name to the spawned GameObject
                spawned.gameObject.name = "Random number name - " + randomEssentials.GetRandomInt(0, 1000).ToString();
            }
        }
        private void Start()
        {
            randomEssentials = new UnityEngine.RandomEssentials();

            //EXAMPLES:
            bool    randomBool            = randomEssentials.GetRandomBool(0.75f);
            int     randomInt             = randomEssentials.GetRandomInt(3, 10);
            float   randomFloat           = randomEssentials.GetRandomFloat(0.5f, 0.1f);
            Vector3 randomVector3         = randomEssentials.GetRandomVector3(0.5f, 0.1f);
            Vector2 randomVector2         = randomEssentials.GetRandomVector2(0.5f, 0.1f);
            int     randomSign            = randomEssentials.GetRandomSign(0.4f);
            bool    randomBoolTrueEnsured = randomEssentials.GetRandomBoolTrueEnsured(3, 10);
            bool    randomDistributedBool = randomEssentials.GetPseudoRandomDistributedBool(5, 0.25f);
            // This variables are not used anywhere, they exist only to help the example.
        }
Beispiel #3
0
        private void Start()
        {
            randomEssentials = new UnityEngine.RandomEssentials();

            //EXAMPLES:
            bool    randomBool            = randomEssentials.GetRandomBool(0.75f);
            int     randomInt             = randomEssentials.GetRandomInt(3, 10);
            float   randomFloat           = randomEssentials.GetRandomFloat(0.5f, 0.1f);
            Vector3 randomVector3         = randomEssentials.GetRandomVector3(0.5f, 0.1f);
            Vector2 randomVector2         = randomEssentials.GetRandomVector2(0.5f, 0.1f);
            int     randomSign            = randomEssentials.GetRandomSign(0.4f);
            bool    randomBoolTrueEnsured = randomEssentials.GetRandomBoolTrueEnsured(3, 10);
            bool    randomDistributedBool = randomEssentials.GetPseudoRandomDistributedBool(5, 0.25f);

            // To make easier the single use of RandomEssentials, the object can be created and used as follows:
            randomBool = UnityEngine.RandomEssentials.GetNew().GetRandomBool();
            randomBool = UnityEngine.RandomEssentials.GetNew(123456).GetRandomBool(); // With custom seed

            // This variables are not used anywhere, they exist only to help the example.
        }