Aiming down sights

I am working on an fps that is pretty much done and i am now just working on details, one of which is accuracy. i want to have bullet spray while shooting but when aiming down the sights of your gun spray is reduced. i am relatively new to scripting (for more of the complex stuff i used assets from the site) and i was wondering if anybody could help me with it?

p.s. sorry its so long hehe

this was asked and answered in this forum thread: Vector rotation

using that as an example, and the initial assumption that your gun site is looking down the positive Z axis, you could take your vector that represents the gun site and rotate it by some small random amount around the X and Y axis. use those random amounts to make quaternions and muliply those two quaternions against the vector that represents the guns aim. that would represent the random spray of bullets around the gun site aim. if the player is in aimed mode, you could reduce the random numbers so that the spray is closer to the true aim.

i haven't messed with the fps tutorial, but there should be a fairly easy way to get the two vectors you need. you can probably use Vector3.up as one and then use the Vector3.Cross() function to get the other vector to rotate around.

If your new to coding and your making a fps I strongly suggest the EteeskiTutorials on youtube. They start you off with nothing and assume you have no scripting knowledge and at the end you have a fully functional fps prototype. Here is a link to the playlist.

I do not get it, I am having the same problem. Could you explain simpler what to do

This weapon tutorial has (almost) everything you need for making your own weapons Dastardlybanana. (Includes low poly weapon models and sounds)