Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject != this.gameObject)
        {
            //Debug.Log("Hit a thing!");
            PlayerHealth healthScriptToDamage = other.gameObject.GetComponent <PlayerHealth>();
            MovementAI   AIToAlert            = other.gameObject.GetComponent <MovementAI>();

            //Debug.Log(other.gameObject.name);

            if (healthScriptToDamage != null)
            {
                //Debug.Log("Got a script!");
                healthScriptToDamage.TakeDamage();
                if (AIToAlert != null)
                {
                    AIToAlert.TurnToCheckASpot(this.gameObject.transform.position - this.gameObject.transform.forward);
                }
            }
            else if (other.gameObject.tag == "Destructable")
            {
                Health enemyHealth = other.transform.GetComponent <Health>();
                if (enemyHealth != null)
                {
                    //Debug.Log("It will be hurt.");
                    enemyHealth.TakeDamage();
                }
            }
            RpcDestroyBullet();
            NetworkServer.UnSpawn(this.gameObject);
            NetworkServer.Destroy(this.gameObject);
        }
    }