Bullet devation

So is there some function that will change projectile deviation. Like when you hip fire the bullets will go in a random direction.

You can probably use this:
http://unity3d.com/support/documentation/ScriptReference/Random.html

Give your bullet random(er) rotations/velocities when you fire from the hip, but make sure it only fires forward!

Thanks Is there anything more specific or just random functions.

I’m afraid Unity does not have a built in “randomize my accuracy based on value” function. So yes, you would have to make use of the random functions.

I’m afraid Dman is right. that is probably the way to go.

bullet.transform.rotation = Quaternion.LookRotation( gun.transform.forward * 1.01 + Random.insideUnitSphere * inaccuracyModifier );

This will choose a random point within a sphere guaranteed to be pointed in the general direction the gun was pointed. 1.01 ensures the result isn’t a zero vector, and the inaccuracy modifier allows you to make the gun more or less accurate. 0.0 for inaccuracy will give you pinpoint accuracy, 0.5 gets you a respectable shotgun, and 1.0 gets you the Heavy’s minigun but without the accuracy. :slight_smile:

This method will make many bullets head approximately where the gun was pointed; if you want to make a more even distribution you can experiment with Random.insideUnitCircle -'s rotated to be perpendicular to the gun.

Thanks now I just need it to decrease over time. Which I can do.