Beispiel #1
0
 void OnCollisionEnter(Collision collision)
 {
     Debug.Log("crash");
     if (collision.gameObject.tag == "Environment")
     {
         _destructable.ModifyHealth(
             (int)-collision.gameObject.GetComponent <Rigidbody>().mass * 3, collision.gameObject);
     }
 }
        void OnTriggerEnter(Collider collider)
        {
            Destructable destructable = collider.gameObject.GetComponent <Destructable>();

            if (destructable != null)
            {
                destructable.ModifyHealth(-Damage, Owner);
                if (!collider.CompareTag("Player"))
                {
                    if (PlayerShipAction.Target == null)
                    {
                        PlayerShipAction.Target = destructable;
                        Owner.GetComponent <PlayerShipAction>().SetTargetUI(destructable);
                    }
                }
            }
            if (collider.CompareTag("Environment"))
            {
                gameObject.SetActive(false);
            }
        }