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

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); 
    } 
主站蜘蛛池模板: 卫辉市| 佛坪县| 化隆| 商河县| 鹰潭市| 萝北县| 和林格尔县| 鄂州市| 金山区| 平谷区| 长阳| 平昌县| 桐柏县| 馆陶县| 凤庆县| 姜堰市| 安龙县| 卓尼县| 博客| 瑞金市| 南澳县| 闻喜县| 阳朔县| 津南区| 韶山市| 水富县| 丰宁| 祁门县| 普宁市| 贡嘎县| 辛集市| 新竹县| 武宁县| 科尔| 合水县| 上犹县| 盐城市| 安庆市| 资溪县| 无锡市| 金寨县|