# How to make my bullets spread when fired

Alright i am making a action/arcade game, where you are a Tank, and you have to go around shooting enemies to gain gems. As it is a arcade type game, i made a power-up that upgrades your gun, from being a single shot, to shooting 3 bullets at the same time. I got that whole part worked out, the problem is, the bullets are instantiated on 3 different SpawnSpots (game object), and they all fly forward of the player. The thing that i want to do is have it so one goes stright forward, the one on the right goes right at a angle, and the one on the left goes at angle to the left. I have no idea how to do this, i figure it is part of rigidbody.AddForce but i do not know which would work, so i could turn, and it would always shoot forward of me, yet slightly angled so it spreads.

You would have to apply a rotation to the bullets after they are instantiated but before you add a force to them. I have a script laying around which gives a bit of a random spread. You can easily modify this so that you have a fixed angle to the left and a fixed angle to the right for those bullets.

``````var bulletPrefab:Transform;
var strayFactor : int;

function Update() {
if(Input.GetButtonDown("Jump")) {

var randomNumberX = Random.Range(-strayFactor, strayFactor);
var randomNumberY = Random.Range(-strayFactor, strayFactor);
var randomNumberZ = Random.Range(-strayFactor, strayFactor);

var bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
bullet.transform.Rotate(randomNumberX, randomNumberY, randomNumberZ);
}
}

``````

So the bullet is instantiated in the exact rotation which you are facing (given that you attach the script to your main camera) and then it adds a rotation (in this case random) and shoots the bullet off by adding the force.

Any Chance you could post you modification?

if u put this in the fireoneshot script or what function u have then the bullets should spread and if u press right mouse button it should spread less handy for if u can aim down sight a little with ur tank

``````var Maxspread: float = 0.03;

//.....

// the total spread along the x y and z

//....

if (Input.GetButton("Fire2"))
{
}
else
{