Calculate spawn yaw within a degree angle (spread pattern)

I’m terrible at math and struggling with getting this right. I need to distribute projectiles evenly during actor spawn (using object pooling) on a 45 degree angle. Number of projectiles may increase/decrease starting from 1. Does anyone know the math for this?

Currently I’ve done (e.g. say there’s 3 projectiles): ( 45 / 2 ) / 3

It’s split in half as this is the top down 3rd person template and not 2D template so working with 2 planes. Then on spawn I subtract or add the offset to the current actor rotation based off the projectile index being odd or even. So I do the following.

Odd: OFFSET * INDEX * -1
Even: OFFSET * INDEX

I then add that to actor z rotation and set that as the spawn z rotation. This, kinda, works but seams off by a few degrees. I’m sure the math is wrong, but having a hard time with it.

Ok, figured out the problem. Needed to keep track of left/right of 0 indexes independently. Was getting the below situation.

Projectiles: 3
Angle: 45
Half Angle: 22.5

0 x 22.5 = 0
1 x 22.5 = 22.5
2 x 22.5 = 45

When I need the below.

0 = 0
1 = 22.5
2 = -22.5

Just added integer nodes for dealing with left/right index idependently.

In case you still want the math:


DirInCone
DirInConeRot