Exemplo n.º 1
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Goal")
        {
            GoalController goal = other.GetComponent <GoalController>();

            if (!goal.IsSunk)
            {
                goal.Trigger();

                // If we're still holding onto the ball, we get the sink, but we don't want to kill it.
                if (isThrown)
                {
                    Destroy(rigidBody);
                    Destroy(GetComponent <Collider>());
                    transform.position = goal.transform.position;
                    fallSpeed          = 0;
                    isSunk             = true;
                    BallSunkEvent(distanceTravelled);
                }
                else
                {
                    BallSunkEvent(distanceTravelled, false);
                }
            }
        }

        if (other.tag == "BlackHole")
        {
            GameObject.Destroy(gameObject);
        }
    }