Haha, don’t be so harsh on yourself! It’s cute, and you know it. Besides, a little enthusiasm is hardly a flaw
As for how to actually implement stuff, I guess that’s quite dependent on what Unity offers. I’m not at all familiar with it, but at a brief glance it looks like mathematical stuff is, to a large extent, absent. So, let’s amuse ourselves with how to do it
For taking an actual shot, I guess any way of drawing from a suitable probability distribution is fine. However, I suspect most shots aren’t actual shots: every time you move your cross-hairs around, in free-aim mode, the game needs to recalculate the expected outcome (damage) of taking precisely that shot, and I would expect these “fake” shots to vastly outnumber the real ones.
Perhaps there are even many enough of them to warrant some performance considerations Let’s assume that, because that’s where the fun is Otherwise, it would just be draw a large sample from the distribution and compute the average of the outcomes
.
What you want, then, is a sample which is highly representative of its underlying probability distribution – a good stencil. You’d use it in just the same way as if drawing a large sample, but you wouldn’t have to perform the draw every time This isn’t the main benefit though – rather, the benefit is that you could choose a nice stencil After all, you’d need a rather dense scatter plot for it be satisfactorily uniform, and you’d really want that, if it was fixed.
What I’d do is to use the golden ratio to draw a sunflower. Really, check out that page; it’s awesome But I’d choose my radial increments to match the desired distribution of accuracy, i.e., I’d let the radius increase as the derivative of the inverse of the cumulative probability distribution over radius / accuracy
Not only would this stencil be most pleasing to the , highly symmetrical and without large gaps (probably what makes it so beautiful ), but it would also be a very nicely distributed sample of the PDF. This would help avoid flickering in expected outcome as the cursor moves around; intuition is its the actually the best possible sampe, of a given size, for this purpose It would also be trivial to compute an expected outcome: simply take the average outcome of all the points of the sunflower. Taking variable accuracy into account would be simple as well – just scale the stencil with the inaccuracy of the shooter
If your stencil was fine enough, you could even reasonably well simulate shots by drawing, with uniform probability, from the . However, for actual shots, there’s just no way drawing a few points is the performance bottleneck. And then again, perhaps Unity offers fast evaluation of Gaussian beams, and you could just shine a “flashlight of probability” from your muzzle towards your target, and see how “illuminated” each surface was? Oh well, I had fun writing this, anyway