void OnTriggerEnter2D(Collider2D col)
 {
     if (col.name == "PolygonCollider")
     {
         gHandler.Enable();
         AudioSource.PlayClipAtPoint(clip, this.transform.position, 0.5f);
     }
 }
Exemple #2
0
    void Update()
    {
        Debug.DrawRay(transform.position, dir * Mathf.Infinity, Color.red, 0f);
        hit  = Physics2D.Raycast(transform.position, dir, TransformFormat.getXVel(1f));
        spot = Physics2D.Raycast(transform.position, dir, Mathf.Infinity);

        if (hit && (hit.collider.tag == "wall" /*|| hit.collider.tag == "doorway"*/ || hit.collider.name == "MainChar"))
        {
            isHit = true;
        }
        else
        {
            isHit = false;
        }

        if (spot && spot.collider.name == "MainChar")
        {
            guardHandler.Enable();
        }
    }