Example #1
0
 // Update is called once per frame
 void Update()
 {
     deltatime = Time.deltaTime;
     if (t < time)
     {
         if (t1 < interval)
         {
             t1 = t1 + deltatime;
         }
         else
         {
             for (i = 0; i < density; i++)
             {
                 randPos2D    = Random.insideUnitCircle * radius;
                 biasPosition = new Vector3(randPos2D.x, 0, randPos2D.y);
                 groundPos    = SwordExplosion.GetGroundPos(myTransform.position, gravity);
                 Vector3 adjustBias = myTransform.position - groundPos;
                 adjustPos  = myTransform.position + new Vector3(adjustBias.x, 0, adjustBias.z);
                 swordClone = (GameObject)Instantiate(swordPrefab, adjustPos + biasPosition, Quaternion.identity);
                 float rand = Random.value;
                 swordClone.transform.localScale = swordClone.transform.localScale * ((1 - rand) * scaleMin + rand * scaleMax);
                 swordClone.transform.parent     = myTransform;
             }
             t1 = 0;
         }
         t = t + deltatime;
     }
 }
Example #2
0
    // Use this for initialization
    void Start()
    {
        swordPrefab.SetActive(false);
        splitPrefab.SetActive(false);
        SwordExplosion swordExplosion = swordPrefab.AddComponent <SwordExplosion>();

        swordExplosion.Init(explosionRadius, power, powerUp, inDepthBias, lastTime, splitLastTime, splitNum, gravity, splitPrefab, physicSplit, splitScaleMin, splitScaleMax);
        myTransform = transform;
        Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Sphere"), LayerMask.NameToLayer("Cube"), true);
        Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Cube"), LayerMask.NameToLayer("Cube"), true);
        Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Sphere"), LayerMask.NameToLayer("Sphere"), true);
        if (scaleMin > scaleMax)
        {
            scaleMin = scaleMax;
        }
    }