ApplyRandVector3() public static method

Add random value to Vector3
public static ApplyRandVector3 ( Vector3 trans, Vector3 randVec, JCS_Bool3 checks ) : Vector3
trans Vector3 transfrorm u want to apply.
randVec Vector3 value for each axis.
checks JCS_Bool3 check for eaxh axis.
return Vector3
コード例 #1
0
        /// <summary>
        /// Spawn a random transform.
        /// </summary>
        public void SpawnATransform()
        {
            int spawnIndex = JCS_Random.Range(0, mSpawnList.Count);

            // check null ref.
            if (mSpawnList[spawnIndex] == null)
            {
                JCS_Debug.Log("Can't spawn a null reference. Plz check the spawn list if there are transform attach or empty slot.");
                return;
            }

            // spawn a object
            Transform objSpawned = (Transform)JCS_Util.SpawnGameObject(
                mSpawnList[spawnIndex],
                this.transform.position);


            // randomize the position a bit.
            Vector3 randPos = JCS_Util.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.position,
                new Vector3(mRandPosRangeX, mRandPosRangeY, mRandPosRangeZ),
                new JCS_Bool3(mRandPosX, mRandPosY, mRandPosZ));

            // randomize the rotation a bit.
            Vector3 randRot = JCS_Util.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.eulerAngles,
                new Vector3(mRandRotRangeX, mRandRotRangeY, mRandRotRangeZ),
                new JCS_Bool3(mRandRotationX, mRandRotationY, mRandRotationZ));

            // randomize the rotation a bit.
            Vector3 randScale = JCS_Util.ApplyRandVector3(
                // use the current spawner position.
                objSpawned.transform.localScale,
                new Vector3(mRandScaleRangeX, mRandScaleRangeY, mRandScaleRangeZ),
                new JCS_Bool3(mRandScaleX, mRandScaleY, mRandScaleZ));

            objSpawned.transform.position    = randPos;
            objSpawned.transform.eulerAngles = randRot;
            objSpawned.transform.localScale  = randScale;
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        private void DoDegreeChangeEffect()
        {
            if (!mDegreeChangeEffect)
            {
                return;
            }

            mDegreeTimer += Time.deltaTime;

            if (mDegreeTimer < mTimeToDegreeChange)
            {
                return;
            }

            // prepare random
            Vector3 randVal = new Vector3(
                mRandDegreeRangeX,
                mRandDegreeRangeY,
                mRandDegreeRangeZ);

            JCS_Bool3 checkers = new JCS_Bool3(
                mRandDegreeX,
                mRandDegreeY,
                mRandDegreeZ);

            // apply it.
            transform.eulerAngles = JCS_Util.ApplyRandVector3(transform.eulerAngles, randVal, checkers);

            // reset timer
            mDegreeTimer = 0;

            // conitnue the effect then dont disable the effect!
            if (!mContinousDegreeChange)
            {
                // end the effect!
                mDegreeChangeEffect = false;
            }
        }