コード例 #1
0
 void OnTriggerEnter(Collider other)
 {
     Right_col = true;
     if (other.gameObject.tag == "NormalEnemy") //一般車と衝突
     {
         GameStateStash.GameOver();
         Destroy(parent.gameObject);
     }
     else if (other.gameObject.tag == "Wall")//壁と衝突
     {
         GameStateStash.GameOver();
         Destroy(parent.gameObject);
     }
     else if (other.gameObject.tag == "Enemy")//特殊敵と衝突
     {
         audiosource.PlayOneShot(SE_hit);
         GameStateStash.BreakCarCountUp();
         GameStateStash.AddScore(10);
         if (player_check.player_move == false)
         {
             right_enemy = true;
         }
         else
         {
             Debug.Log("Blast!!");
             var rigid   = other.gameObject.GetComponent <Rigidbody>();
             var impulse = (rigid.position - transform.parent.position).normalized * impulse_Power;
             rigid.AddForce(impulse, ForceMode.Impulse);
             //other.transform.position = Vector3.MoveTowards(other.transform.position,
             //    new Vector3(other.transform.position.x + 4, 0.5f, 0), 200 * Time.deltaTime);
         }
     }
 }
コード例 #2
0
 void OnTriggerEnter(Collider other)
 {
     Left_col = true;
     if (other.gameObject.tag == "NormalEnemy")//一般車と衝突
     {
         hit_SE.PlayOneShot(SE_hit);
         GameStateStash.GameOver();
         Destroy(parent.gameObject);
     }
     else if (other.gameObject.tag == "Wall")//壁と衝突
     {
         hit_SE.PlayOneShot(SE_hit);
         GameStateStash.GameOver();
         Destroy(parent.gameObject);
     }
     else if (other.gameObject.tag == "Enemy")//特殊敵と衝突
     {
         hit_SE.PlayOneShot(SE_hit);
         GameStateStash.BreakCarCountUp();
         GameStateStash.AddScore(10);
         if (player_check.player_move == false)
         {
             left_enemy = true;
         }
         else
         {
             var rigid   = other.gameObject.GetComponent <Rigidbody>();
             var impulse = (rigid.position - transform.parent.position).normalized * impulse_Power;
             rigid.AddForce(impulse, ForceMode.Impulse);
             Debug.Log("Blast!!");
         }
     }
 }
コード例 #3
0
ファイル: Hit_Back.cs プロジェクト: wkgwmasatake/Chase-Crash
 void OnTriggerEnter(Collider other)
 {
     Back_col = true;
     if (other.gameObject.tag == "NormalEnemy")
     {
         hit_SE.PlayOneShot(SE_hit);
         GameStateStash.GameOver();
         Destroy(parent.gameObject);
     }
 }