void RayCasting() { RaycastHit2D hit = Physics2D.Raycast(sightStart.position, -Vector2.down); if (hit.collider != null) { GameControllerScript1.vidaDecrement(); Destroy(hit.collider.gameObject); } }
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); } }