2D Swarm Homing Rockets - Random Movements to target

Hi all, this is my first post
!

Anyway, I am practicing my coding and I have tasked myself to develop a top down (transform
.up as NORTH) gun that will shoot rockets towards a target, perhaps moving or stationary.

My original idea was to find the rotation between the current object and the target, and then add a few degrees positive or negative to make it have a “spray” feel
(instead of all the rockets flying straight
at the same time, it may feel natural for them to start by going their own way then moving with a bit of randomness / arching to the final target.

My attempt
as follows:

    public Transform target;
    public float speed = 6f;
    public float dist;
    public Quaternion face;
    public float rotSpeed = 6f;
    public float offset = 0f;
    public float angle;


    private float time;
    private float timer = 0.0f;

    private float xPow;
    private float yPow;

    private Vector2 prevPos;
    private Vector2 startPos;
    private Transform trans;

    private void Start()
    {


        dist = Vector2.Distance(gameObject.transform.position, target.position);

        angle = Mathf.Atan2(target.position.y - transform.position.y, target.position.x - transform.position.x) * Mathf.Rad2Deg + (offset - 90);

        Quaternion rot = Quaternion.AngleAxis(angle, Vector3.forward);

        float add = Mathf.Rad2Deg + (Random.Range(-20f, 20f));

        Quaternion result = rot * Quaternion.AngleAxis(add, Vector3.forward);

        transform.rotation = result;
    }

    private void Update()
    {
        Vector2 vect = startPos;

        vect.x = Mathf.Lerp(vect.x, target.position.x, Mathf.Pow(timer / time, xPow));
        vect.y = Mathf.Lerp(vect.y, target.position.y, Mathf.Pow(timer / time, yPow));

        trans.position = vect;
        timer += Time.deltaTime;

        if (((Vector2)trans.position) != prevPos)
        {

            float angle = Mathf.Atan2(target.position.y - transform.position.y, target.position.x - transform.position.x) * Mathf.Rad2Deg + (0);

            Quaternion rot = Quaternion.AngleAxis(angle, Vector3.forward);
            transform.rotation = Quaternion.Slerp(transform.rotation, rot, (3 * Time.deltaTime));
        }

        prevPos = trans.position;

        if (timer > time)
        {
            Destroy(gameObject);
        }
    }
}

I would like to note that a fair amount of that code was written by user ‘@robertbul’. I was trying to make it work with 2D.
Now my code does work slightly where the rocket moves to the target, but when it is in
direct line (every 90 degrees around the target), the rockets fire in a line.
I also tried to experiment with a system where the rocket starts slowly then increases speed at the end by messing around with the
Mathf.Pow stuff but that didn’t work ;/

I haven’t run the code but first thing that pops out is the inappropriate use of the Mathf.Rad2Deg constant.

On line 26 the usage looks nominal.

However on line 30 you are adding it to a random number. This is essentially meaningless, unless you want to add 360.0f / pi to your offset, which I highly doubt.

The point of Rad2Deg is to use it to multiply from functions that return radians (such as Mathf.Atan2 and so on) to functions that accept degrees (Quaternion.Euler).

The best way to get to the bottom of this will be to fire two known rockets, with preset offsets, say +0 and +20, and then use Debug.Log() to output each of the intermediate steps and values calculated, and fix any that are suspect/incorrect.