示例#1
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Projectile")
        {
            controller.KillEnemy(this.gameObject);
            explosionEffect.GetComponent <ParticleSystem>().startColor = new Color(Random.Range(0, 255), Random.Range(0, 255), Random.Range(0, 255));
            Instantiate(explosionEffect, collision.contacts[0].point, Quaternion.identity);

            Kill();
        }
        if (collision.gameObject.tag == "Player")
        {
            player.GetComponent <PlayerController>().Hit(this.gameObject);
            GetComponent <Rigidbody>().AddForce((-this.transform.forward) * playerHittedRecoil, ForceMode.Impulse);
        }
    }