Пример #1
0
 private void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Player")
     {
         deflagration.Player p = gameObject.GetComponent(typeof(deflagration.Player)) as deflagration.Player;
         p.killPlayer();
         Debug.Log("touché");
     }
 }
    /*
     * private void OnTriggerEnter(Collider col)
     * {
     *  if (col.gameObject.tag == "Player")
     *  {
     *      Destroy(gameObject);
     *      Debug.Log("touché");
     *  }
     *
     * }
     */

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.gameObject.tag == "Player")
        {
            deflagration.Player p = collision.collider.gameObject.GetComponent(typeof(deflagration.Player)) as deflagration.Player;
            p.killPlayer();
            Debug.Log("touché");
        }
        if (collision.collider.gameObject.tag == "Movable")
        {
            GameObject col = collision.collider.gameObject;
            col.GetComponent <Rigidbody>().AddForce(0, forcey, forcez, ForceMode.Impulse);
        }

        Destroy(gameObject);
    }