fireing a projectile fan

hi,

i want create a prjectiel-fan ( http://prntscr.com/2yyx2v )

GameObject next = Instantiate(Perceptionprojectiel, transform.position + 0.5f * transform.forward, transform.rotation) as GameObject;

my problem is i don’t know how to adjust the rotation quarternion in dependence of the orientation of the shooter (only one axis and without realy change the orientation)

if possible i want that the number of projectiels and the and the maximum angle is adjustable…

(sorry english is not my first language)

for help I would be very grateful

Tom

Quaternion.AngleAxis() can be used to rotate a vector. I’m guessing for your fan, you want the forward of your object to be the center firing vector, and you want to rotate around the up of your object for the fan. Here is the four rotated vectors calculated by hand with 10 degrees between them:

var center = transform.forward;
var rightMost = Quaternion.AngleAxis(-20, transform.up) * center;
var right = Quaternion.AngleAxis(-10, transform.up) * center;
var left = Quaternion.AngleAxis(10, transform.up) * center;
var leftMost = Quaternion.AngleAxis(20, transform.up) * center;

Note the pattern (rotating center by -20, 10, 0, 10 20). You can easily rewrite this a for() loop rather than individual rotated vectors.