I’m currently using 6 bullets, and the spread is calculated using
FMath::VRandCone
.
Sometimes, bullets are too close to each other and, the target is receiving 3 or more bullets from far distance.
So, the questions are
1- Is it possible to make FMath::VRandCone respect a distance between each random value?
2- If not, how do we create a fixed spread?
Random is random. You can get all 6 shots on the same point in theory. If you want it to respect distances between shots, you have to throw away values that are too close to already existing shots.
For a fixed spread, you would just use sin/cos to build your shot points.
You should look at Unreal Tournaments Flak canon code as that’s essentially the same thing as a shotgun.
ExtraLifeMatt:
Random is random. You can get all 6 shots on the same point in theory. If you want it to respect distances between shots, you have to throw away values that are too close to already existing shots.
For a fixed spread, you would just use sin/cos to build your shot points.
You should look at Unreal Tournaments Flak canon code as that’s essentially the same thing as a shotgun.
I’ve implemented a function to make the spread “semi-fixed” random, dividing the spherical coordinates to multiple sections.
By doing this, bullets are not close to each other, respecting the distance between bullets.
6 concentric rings. Each bullet has a Min & Max dist from center, and a random 360. Less random, more control.
MarkcusD
(MarkcusD)
February 27, 2020, 1:55am
5
Shooter game has some spread code in it.