예제 #1
0
    void RayCasting()
    {
        RaycastHit2D hit = Physics2D.Raycast(sightStart.position, -Vector2.down);

        if (hit.collider != null)
        {
            GameControllerScript1.vidaDecrement();
            Destroy(hit.collider.gameObject);
        }
    }
예제 #2
0
 void RayCasting()
 {
     Debug.DrawLine(sightStart.position, sightEnd.position, Color.red);
     if (Physics2D.Linecast(sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer(tagOfObj)) && gameObject.tag == tagOfObj)
     {
         AudioSource.PlayClipAtPoint(clip, transform.position);
         GameControllerScript1.addScore();
         Destroy(gameObject);
     }
     if (Physics2D.Linecast(sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("Player")))
     {
         GameControllerScript1.vidaDecrement();
         Destroy(gameObject);
     }
 }