I'm not very good with angles, in reference to shotguns

I am trying to make a raycast shotgun and I’m wondering how I modify the rotation of a transform (not rotate it but take the value and change it for a different raycast with the transform as the origin) with script. I’m not very experienced with using angles and vectors so any help would be great.

Two easy ways:

  1. multiply a Quaternion by a Vector to “turn” that Vector by the Quaternion:
Vector3 bentDirection = Quaternion.Euler( 0, 45, 0) * originalDirectionVector;
  1. add a small amount to the vector and renormalize it:
Vector3 bentDirection = (originalDirectionVector + Random.insideUnitSphere * 0.1f).normalized;

Plenty of other ways to perturb data, and many ways to source the above perturbations, but there you go.

thanks Kurt! lifesaver as always

1 Like