Not quite true. Even if the center of the circle is 1 unit away from you, the distance between you and the chosen point on that circle is not 1 unit. Obviously, the entire circle can't be the same distance away from you! So you have to account for the actual distance between you and the point on the circle being used for the trace, since that differs from the distance between you and that circle's center. This would require some more squares and square roots.Dragon wrote:No need for that. Nobody prevents you from choosing 1 as the distance where you calculate your circle. So it all boils down to multiply the result by the distance to the end of the trace (typically the firing range).G-Flex wrote:Like you were saying, what you would need to do is: Draw the circle at some constant distance from the player's view (instead of a distance relative to maximum range), and draw the trace to there, but extend the trace to such a length that the weapon's range is respected. Of course, this would require calculating the distance between the viewpoint and that point on the circle, so you'd know how far to extend/retract the trace.
Define "need". I said that the distribution is different, not worse. With my method, the angle of fire is flatly distributed between 0 and the maximum (as determined by accuracy). With your method, the distance of the bullet hole from the center of a circle is flatly distributed. These aren't the same thing, and the latter results in more shots landing on the outside of the circle. Which one you think is more "correct" is a matter of opinion. I personally feel it's more reasonable for firing angle to be flatly distributed (e.g. if your shot can be between 1 degree off and 3 degrees off, all angles within that range are equally likely), whereas you apparently feel it's more reasonable for the distance from center on a hypothetical surface straight ahead within the firing circle to be flatly distributed (e.g. if your shot at a wall ten feet away can be between 1 inch and 3 inches off, all distances from center within that range are equally likely). My solution is more similar to how actual gunfire would work.That's though not correct. You do not need an even distribution in the cone. What you need is an even distribution in the target circle as if the circle is painted on a wall and you shot at it.
It's not the same solution. You like yours better and I like mine better, but they are not mathematically equivalent.The formula I gave is mathematically correct and evenly distributed in the circle. Furthermore the maximum spread angle is an input variable as you requested. So you have everything you need:
1) upper spread angle limit as input variable (angle based spread)
2) even distribution in a circle (circular impact shape, mathematically correct as long as PRNG is good enough)
3) easy and fast to calculate (requires only one sin, cos and tan)
So what is missing so it is not a viable solution?
"Even distribution is a circle" is only "mathematically correct" in the sense that it's what you apparently think the situation should be. If the firing angle is what is flatly distributed, then the shots within the hypothetical circle will not be flatly distributed. I feel it makes more sense for the firing angle to be distributed evenly than the points on the circle, and certainly trying to distribute the shots evenly per unit area on the circle makes even less sense to me.
I also don't understand how you plan to do any of this using only one randomized variable. That doesn't conceptually make any sense to me. Not only must you randomize the size of the cone (radius, firing angle, however you want to do it), but you also need to randomize where on that cone the trace falls. I do not believe it is conceptually possible to do this using only one randomized input.
In conclusion: You're right that your basic concept works. However, the shot distribution is not "more correct" except for some particular (and in my opinion very strange) concept of what "correct" distribution should be, it requires more math than you say it does, and you would have to be very careful to make sure the targeting reticule still matches your accuracy, since the targeting reticule is inherently angle-based with the angle varying linearly with accuracy (although you can certainly change how this is calculated as well). The shot distribution could definitely be made more my definition of "correct" if you randomize the spread angle instead of the radius and go from there, of course.