So, Something like a bullet hell?

Or a straight beam?

The two follow a very similar principle, the only difference is how you manage the velocity.
In the first image, I didn’t parent the, let’s call them bullets just for the sake of clarity. I instantiated a bullet then set its movement speed, that’s it.
In the case of the straight beam, I needed to parent the bullets to the rotating object, but, the speed of each bullet is managed separately, each bullet will need its own script to update its speed as they rotate with the parent object.
I suppose you want the straight line, so here's the code.
public class RotateTowards : MonoBehaviour
{
[SerializeField] Transform player;
[SerializeField] float rotationSpeed;
[SerializeField] float fireRate;
[SerializeField] GameObject prefab;
float fireTime;
void Update()
{
Vector3 playerDirection = transform.position - player.position;
float beamPlayerAngle = Vector2.Angle(transform.up, playerDirection);
beamPlayerAngle = Vector2.Angle(transform.right, playerDirection) > 90 ? 360 - beamPlayerAngle : beamPlayerAngle;
float angleSpeed = beamPlayerAngle < 180 ? rotationSpeed : -rotationSpeed;
transform.Rotate(Vector3.forward, Time.deltaTime * angleSpeed);
if (Time.time >= fireTime)
{
fireTime = Time.time + fireRate;
Instantiate(prefab, transform.position, transform.rotation, transform);
}
}
}
public class Bullet : MonoBehaviour
{
[SerializeField] Rigidbody2D rb;
[SerializeField] float speed;
private void Update()
{
rb.velocity = transform.up * speed * Time.deltaTime;
}
}
You could achieve the same effect with a single script and a loop, but that would complicated things way too much, you’ll have to check for nulls, and know when and how to modify the list so it doesn’t become an endless list of nulls, and so on, not recommended.
There’s another solution, if you want a straight beam, you can make it collide with obstacles.

I think that looks way cooler than the constant bullets.
Here's the code.
public class BeamOfDoooooooom : MonoBehaviour
{
[SerializeField] Transform player;
[SerializeField] float rotationSpeed;
[SerializeField] LayerMask obstacleMask;
Vector3 initialBeamScale;
private void Awake()
{
initialBeamScale = transform.localScale;
}
void Update()
{
Vector3 playerDirection = transform.position - player.position;
float beamPlayerAngle = Vector2.Angle(transform.up, playerDirection);
beamPlayerAngle = Vector2.Angle(transform.right, playerDirection) > 90 ? 360 - beamPlayerAngle : beamPlayerAngle;
float angleSpeed = beamPlayerAngle < 180 ? rotationSpeed : -rotationSpeed;
transform.Rotate(Vector3.forward, Time.deltaTime * angleSpeed);
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up, Mathf.Infinity, obstacleMask);
if (hit.collider != null)
{
Vector2 transformPosition = transform.position;
float yScale = (transformPosition - hit.point).magnitude;
Vector3 newScale = transform.localScale;
newScale.y = yScale;
transform.localScale = newScale;
}
else { transform.localScale = initialBeamScale; }
}
}
You can use a CircleCast instead of a Raycast, it would depend on the type of effect you are aiming for.
Hope this helps.