Exemplo n.º 1
0
    // on TRIGGER enter
    private void OnTriggerEnter(Collider other)
    {
        //se o player colidir com a poção && o player não estiver segurando outra poção,
        PotColi pc = other.GetComponent <PotColi>();

        if (other.gameObject.CompareTag("Potion") && holding == false && pc != null && !other.GetComponent <PotColi>().getThrown())
        {
            //segura esta poção:
            holding = true;
            other.gameObject.transform.SetParent(holdpoint);
            other.gameObject.transform.position = holdpoint.position;
            potionRigidbody = other.gameObject.GetComponent <Rigidbody>();
            //K: pra que mexer no isKinematic?
            potionRigidbody.isKinematic = false;

            potionRigidbody.gameObject.GetComponent <Collider>().enabled = false;

            //J: adquire script da poção arremessada e altera o valor de qual time carrega/arremessa a poção
            potionScript = pc;
            potionScript.setThrower(throwerTeam);
        }
        else if (other.gameObject.CompareTag("Potion") && holding == true && pc != null && !other.GetComponent <PotColi>().getThrown())
        {
            //J: ao colidir com orbe no chão enquanto carrega outra orbe, desativa sua colisão
            if (numIgnore <= 10)
            {
                Debug.Log("Novo Ignorado");
                other.enabled = false;
                numIgnore++;
                ignorados[numIgnore - 1] = other;
            }
        }
    }