No way to use Raycast infront of player according to rotation in 2D?

Im trying to raycast in front of the player. My game is in topdown perspective and the player can move freely (so simply doing Vector2.up and Vector2.right and so forth doesn’t work most of the time).

So far I’ve painstakingly used switch cases for the most common angles, but this is very noticable during gameplay because most angles aren’t covered. The problem is that there doesn’t seem to be a transform.forward equivalent for 2D, and because the the Physics2D.Raycastmethod requires a Vector2, and there’s no way to convert transform.rotation.z to that required Vector.

This the code I have so far.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShootingBehaviour : MonoBehaviour
{
    public GameObject Missile;
    public float movementSpeed = 50;
    public GameObject shootTowards;

    void Update()
    {   
        if (Input.GetKeyDown(KeyCode.Space))
        {
            RaycastHit2D hit = CalcHit(transform.rotation.z);
            if (hit.collider != null)
            {
                Destroy(hit.collider.gameObject);
                Debug.DrawRay(transform.position, hit.collider.transform.position, Color.red);
                Debug.Log(hit.collider.gameObject.name);
            }
        }
    }

    public RaycastHit2D CalcHit(float rotation)
    {
        Vector2 offsetPos = new Vector2(transform.position.x + 30, transform.position.y + 30);
        switch (transform.rotation.z)
        {
            case 0:
                return Physics2D.Raycast(offsetPos, Vector2.right, 1000f, 1 << 8);
            case 45:
                return Physics2D.Raycast(offsetPos, new Vector2(1, 1), 1000f, 1 << 8);
            case 90:
                return Physics2D.Raycast(offsetPos, Vector2.up, 1000f, 1 << 8);
            case 135:
                return Physics2D.Raycast(offsetPos, new Vector2(1.5f, 1.5f), 1000f, 1 << 8);
            case 180:
                return Physics2D.Raycast(offsetPos, Vector2.left, 1000f, 1 << 8);
            case -135:
                return Physics2D.Raycast(offsetPos, new Vector2(-1f, -1f), 1000f, 1 << 8);
            case -90:
                return Physics2D.Raycast(offsetPos, Vector2.down, 1000f, 1 << 8);
            case -45:
                return Physics2D.Raycast(offsetPos, new Vector2(0.5f, 0.5f), 1000f, 1 << 8);
        }
        return Physics2D.Raycast(offsetPos, Vector2.right, 1000f, 1 << 8);
    }
}

Try Vector2.right, there’s also up and then the negatives of both, but I usually use Vector2.right and as long as the player sprite is initially facing right this should work, otherwise you can use the others mentioned.,Try Vector2.right, theres also up and then the negatives of both, but I usually use Vector2.right and as long as the player sprite is initially facing right this should work, otherwise you can use the others mentioned.