九、创建行星和摧毁行星
1.旋转功能,获取物体的角速度旋转angularVelocity,和随机insideUnitSphere让行星旋转。
2.创建空为Asteroid,拖入行星,父类逻辑控制,子类纹理,利用OnTriggerEnter触碰方法摧毁接触物体,利用tag==“Boundary”来标记Boundary。
十、行星爆炸效果
1.实例化爆炸效果。OnTriggerEnter
2.加入移动脚本。
void OnTriggerEnter(Collider other)
{
if (other.tag == "Boundary")
{
return;
}
Instantiate(explosion, transform.position, transform.rotation);
if (other.tag == "Player")
{
Instantiate(playerExplosion,other.transform.position, other.transform.rotation);
gameController.GameOver();
}
gameController.addScore(score);
Destroy(other.gameObject);
Destroy(gameObject);
}