I was able to move the pivot point, the rectangle rotates behind the cursor, but does not match the real raycast :(
RaycastHit2D[] hits = Physics2D.BoxCastAll(transform.position, new Vector2(attackRangeX, attackRangeY), 0f, transform.right, whatIsEnemies);
private void OnDrawGizmosSelected() { Gizmos.color = Color.green; Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one); Gizmos.DrawWireCube(Vector2.right * 2f, new Vector2(attackRangeX, attackRangeY)); }
and the usual raycast works correctly, the line goes from the center of the character to a right behind the cursor
Debug.DrawRay(transform.position, transform.right * max_distance, Color.green); RaycastHit2D[] hitCenter = Physics2D.RaycastAll(transform.position, transform.right * max_distance, 4f, whatIsEnemies);
I understand that I don’t understand anything at all