As far as I can read, lines 53 to 55 use cartesian coordinates to make an angle.
That won’t work.
Here’s the magic sauce:
Use Mathf.Atan2() to derive heading (angles) from cartesian coordinates:
Sine/Cosine/Atan2 (sin/cos/atan2) and rotational familiarity and conventions
So… either add the two vectors to get the average and use that to make an angle… Or
Compute the two angles and compute the angle between, probably by Mathf.MoveTowardsAngle(), but the vector addition solution might be best.