コード例 #1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Terrain") // hitting any terrain
     {
         // stick the spear
         spear_rb.Sleep();
         spear_rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
         spear_rb.isKinematic            = true;
         can_pick_up = true;
     }
     else if (collision.gameObject.tag == "Bunny")
     {
         Bunny bunny            = collision.gameObject.GetComponent <Bunny>();
         int   remaining_health = bunny.GetHealth();
         remaining_health -= spear_damage;
         if (remaining_health <= 0)
         {
             bunny.SetHealth(remaining_health);
             bunny.spear_go = this.gameObject;
             bunny.SkewerBunnyWrapper();
             // make bunny ghost mode
             bunny.MakeGhostWrapper();
             bunny.Die();
         }
     }
     if (PhotonNetwork.IsMasterClient)
     {
         photonView.RPC("FadeOut", RpcTarget.All);
     }
 }