Shotgun Turret Spread Help

Hello everyone, I need some help with a Shotgun Turret Spread. Every time this turret shoots, it’s bullets are suppose to spread like BB’s of a shotgun. But it just doesn’t, and I feel like I’m close, but I’m missing something, please help.

public GameObject[ ] BB; // shots inside of a shot
public GameObject enemy;
public float throwPower = 25f;
private float mySpeed = 5f;
private float maxDistance = 5f;
private float myDist;
private float spreadRate = 100;
public int bDamage = 10;

void Update ()
{
if (gameObject.tag == “ShotGunShell” && isFired == true)
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
for (int i = 0; i < numOfShots; i++)
{
Instantiate(BB[numOfShots], transform.position, transform.rotation);
}

transform.Translate(Vector3.up * Time.deltaTime * mySpeed);

forward.x += Random.Range(spreadRate, -spreadRate);
forward.y += Random.Range(spreadRate, -spreadRate);
forward.z += Random.Range(spreadRate, -spreadRate);

BB[numOfShots].transform.LookAt(forward);

myDist += Time.deltaTime * mySpeed;
if (myDist > maxDistance)
{
Destroy(gameObject);
print(“Obj Gone”);
//checks to see if the bullet has passed the maximum distance it can travel
//and if it dis destroy the object
}

If your projectiles are using rigidbodies, you’ll need to change the velocity of the Rigidbodies to get the behaviour you’re expecting.

To simulate a true spread, you need to be creating a bullet object at the barrel, rotating them on x and y to a random degree, and then having them move forward with their new rotations. Right now you’re just giving them random offsets over time, which won’t quite have the same effect.