I would like to know how I would create an array of rotations/floats based on the index and total. In the pic above the circle represents the transform/bullet origin. 1 would be the starting rotation which would be straight down, 2 would split from each side, 3 would have one in the middle and split from each side based on the offset. With this formula would it be possible to create something that creates a pattern that fans out evenly from each side?
You want directions not rotations, honestly. A simple array of Vector3 values can be used to determine directions local to the object they’re firing from.
Interesting! I’m kinda opposite… I would usually make a table of relative rotations on either side.
I would put them into a generator so they would yield something like:
0, -1, +1, -2, +2, -3, +3… in sequence
Then your fire routine would reset that generator and iterate it X times if it has X bullets to fire.
- first bullet straight ahead +0
- second bullet turned left -1 x konstant degrees
- third bullet turned right +1 x konstant degrees
… etc
I calculate degrees relative with Quaternion.Euler() and multiply against the Vector to get direction.
Suppose that makes sense too. I could also see a simple solution using both the number of shots + rotation between each shot.
Thus the your first shot starts turned left/right by shotRotation * numberOfShots / 2f
(half the total expect rotation), and then rotate that vector n times for each shot by the rotation between each shot.
Simple and only uses two values.
Of course were I making a scmup game I’d design all kinds of way for me to determine shot patters because that honestly sounds rather fun.