Advertisement
sergezhu

Untitled

Dec 12th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. public void Break()
  2.     {
  3.         Debug.Log("Count to break : " + _humanInTower.Count);
  4.  
  5.         for(int i = 0; i < _humanInTower.Count; i++)
  6.         {
  7.             Transform t = _humanInTower[i].transform;
  8.            
  9.             int sign = (i % 2 == 0) ? -1 : 1;
  10.             Vector3 forceDir = (t.right * Random.Range(1, 10) * sign + t.forward + t.up * 0.5f).normalized;
  11.  
  12.             t.parent = null;
  13.             Rigidbody rb = t.gameObject.AddComponent<Rigidbody>();
  14.             rb.isKinematic = false;
  15.             rb.AddForce(forceDir * 500);
  16.         }
  17.        
  18.         Destroy(gameObject, 3f);
  19.         //Destroy(gameObject);
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement