Exemplo n.º 1
0
    void  OnControllerColliderHit(ControllerColliderHit hit)
    {
        //  Debug.DrawRay(hit.point, hit.normal);

        if (hit.gameObject.tag == "Candy")
        {
            if (hit.moveDirection.y < -0.8 && hit.normal.y > 0.5 && hit.gameObject.layer == 9)
            {
                activePlatform = hit.collider.transform;
            }
        }
        if (hit.moveDirection.y > 0.01f)
        {
            return;
        }

        if (id == 2 && hit.gameObject.tag == "DoorHinge")
        {
            //Rigidbody body = null;
            Rigidbody body = hit.gameObject.GetComponent <Rigidbody>();
            if (body != null)
            {
                body.AddForce(moveDirection * 50);
            }
        }

        if (hit.gameObject.tag == "Candy" && candyTime < Time.time)
        {
            Candy candy = (Candy)hit.gameObject.GetComponent <Candy>();
            candy.PlayAudio();
            candyTime = Time.time + candyInterval;
        }
    }