# can i do this in RayCast

Can i make RayCast Between Two anger E.g between Vector3.forward and Vector3.right

Yes you can. You need to rotate a vector around the cross product of the two vectors. The general case is like this:

``````  var vector = Quaternion.AngleAxis(45, Vector3.Cross(transform.forward, transform.right)) * transform.forward;
``````

Where that 45 is the angle away from the forward direction. Specifically with transform.forward and transform.right you will find the cross product is always transform.up so you can simplify it to:

``````  var vector = Quaternion.AngleAxis(40, transform.up) * transform.forward;
``````

Then raycast against that direction.

If you need to find the ray that is halfway between two arbitrary angles - which as @Fattie points out is what you probably want to do then this:

``````    var vector = Quaternion.AngleAxis(Mathf.Acos(Vector3.Dot(vector1, vector2))/2, Vector3.Cross(vector1, vector2)) * vector1;
``````

If you want to do multiple ray casts between two vectors then this code will do 10:

``````   var differenceInAngle : float = Mathf.Acos(Vector3.Dot(vector1, vector2));
var axis = Vector3.Cross(vector1, vector2);
var rotation = Quaternion.AngleAxis(differenceInAngle/10, axis);
var scan = vector1;
for(var i : int = 0; i < 10; i++, scan = rotation * scan)
{
//Ray cast using scan
}
``````