Answers for "Raycasting at an offset angle?"
http://answers.unity.com/questions/733002/raycasting-at-an-offset-angle.html
The latest answers for the question "Raycasting at an offset angle?"Answer by cosmin2dor
http://answers.unity.com/answers/1397691/view.html
While every other answer is valid for this particular question, I want to answer you more general.
So, everytime when you need to rotate a vector by a certain amount of degrees you should look into Rotation Matrix. Just google it for details.
![alt text][1]
Remeber that the angle is in Radians form here.
Now in order to compute the rotation, you have to multiply your original vector with this R (R*V not V*R!).
After multiplication you should get this
![alt text][2]
[1]: /storage/temp/100473-matrix.png
[2]: /storage/temp/100474-matrix2.png
Now the vector [x', y'] is the rotated version of the original [x, y].
All you have to do in code is to right the two equations and transform the angle input into Radians.
This exemple applys only in 2D, if you want more axes, the concept is the same, except bigger Matrices. Check it out on Wikipedia: https://en.wikipedia.org/wiki/Rotation_matrix
Also you should notice that this is a really powerful approach and it can be used at any sort of vector rotation and in multiple dimensions.Wed, 23 Aug 2017 10:44:19 GMTcosmin2dorAnswer by skinnywhitegamedev
http://answers.unity.com/answers/1155518/view.html
The simplest way I've found to accomplish this is to declare the offset vector3's by multiplying your quaternion angle axes by your forward axis, offsetting in the process from the up axis:
//Setting up Vector3's for rays
Vector3 rayPosition = new Vector3(transform.position.x, headHeight, transform.position.z);
Vector3 leftRayRotation = Quaternion.AngleAxis(-fovAngle, transform.up) * transform.forward;
Vector3 rightRayRotation = Quaternion.AngleAxis(fovAngle, transform.up) * transform.forward;
//Constructing rays
Ray rayCenter = new Ray(rayPosition, transform.forward);
Ray rayLeft = new Ray(rayPosition, leftRayRotation);
Ray rayRight = new Ray(rayPosition, rightRayRotation);
//(Doing things with rays...)
I then messed with the exposed "headHeight" and "fovAngle" variables in the editor.Tue, 15 Mar 2016 20:51:36 GMTskinnywhitegamedevAnswer by Crayz
http://answers.unity.com/answers/733037/view.html
Well after a few hours and a little break in between I figured out what I need to do. For anybody else curious simply just multiply the vector by a quaternion along a single axis. There seems to be a few other methods of angling vectors (Euler angle?) though I'm not too sure about it yet. If anybody has suggestions please post
Vector3 noAngle = spawn.forward;
Quaternion spreadAngle = Quaternion.AngleAxis(-15, new Vector3(0, 1, 0));
Vector3 newVector = spreadAngle * noAngle;
Ray ray = new Ray (spawn.position, newVector);
CastProjectiles(shotDistance, ray);Mon, 23 Jun 2014 04:25:27 GMTCrayz