官术网_书友最值得收藏!

The Dead state

If the tank has reached the Dead state, we make it explode:

    protected void UpdateDeadState() 
    { 
      //Show the dead animation with some physics effects 
      if (!bDead) 
      { 
        bDead = true; 
        Explode(); 
      } 
    } 

Here's a small function that will give a nice explosion effect. We just apply an ExplosionForce function to our rigidbody component with some random directions, as shown in the following code:

    protected void Explode() 
    { 
      float rndX = Random.Range(10.0f, 30.0f); 
      float rndZ = Random.Range(10.0f, 30.0f); 
      for (int i = 0; i < 3; i++) 
      { 
        rigidbody.AddExplosionForce(10000.0f,  
        transform.position - new Vector3(rndX, 10.0f,  
        rndZ), 40.0f, 10.0f); 
        rigidbody.velocity = transform.TransformDirection( 
        new Vector3(rndX, 20.0f, rndZ)); 
      } 
 
      Destroy(gameObject, 1.5f); 
    } 
主站蜘蛛池模板: 吉木萨尔县| 同心县| 闵行区| 翼城县| 布拖县| 教育| 平潭县| 鹤山市| 疏附县| 犍为县| 巴楚县| 泾阳县| 志丹县| 通江县| 眉山市| 广昌县| 句容市| 赞皇县| 永德县| 舞阳县| 永城市| 微博| 盈江县| 平阳县| 福建省| 德兴市| 雷山县| 池州市| 大厂| 珠海市| 金秀| 安福县| 临沧市| 克山县| 稻城县| 辽宁省| 舞阳县| 定边县| 平乡县| 汕尾市| 喀什市|