Example #1
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (!canControl)
        {
            return;
        }

        if (other.gameObject.CompareTag("Platform"))
        {
            CheckPlatform(other);
        }

        else if (other.gameObject.CompareTag("SpookZone"))
        {
            if (Input.GetKeyDown(KeyCode.J))
            {
                Kid kid = other.GetComponentInParent <Kid>();
                kid.GetSpooked(transform.position);
            }
        }

        else if (other.gameObject.CompareTag("WinZone"))
        {
            AudioSource.PlayClipAtPoint(VictoryClip, transform.position);
            _animator.Play("victory");
            _controller.velocity    = Vector2.zero;
            canControl              = false;
            CelebrationText.text    = "CONGRATULATIONS! \nYOU DID IT!!!";
            CelebrationText.enabled = true;
        }
    }