RaycastHit2D[] hits = Physics2D.BoxCastAll(transform.position, new Vector2(1, 1), 0f, Vector2.right, 5f);
RaycastHit2D[] hits = Physics2D.BoxCastAll(transform.position, new Vector2(1, 1), 60f, transform.right, 5f);In the above examples, the BoxCastAll function is used to cast a box-shaped physical ray with a 1x1 size at a distance of 5 units in the right direction from the current game object. In the second example, the ray is oriented at 60 degrees from the right direction of the game object. Package Library: The BoxCastAll function is provided by the Unity Physics2D package library.