Hey guys! I am creating a weapon shooting system that works via a line trace. I was wondering if there would be a way to add a little randomness to the line trace when my character is not zoomed in, a little like a weapon spread system, so my guns will be more accurate when I am zoomed in. Is there any way to do this? Any advice would be appreciated! Thanks so much!
Try something like this:
This will spawn projectiles like a shotgun…Rounds Per Shot is how many will spawn at once and Projectile Spread is the Spread amount in degrees…Projectile Spawn Transform is where the projectiles should spawn (either the muzzle’s transform or wherever you are wanting them to spawn).
Opps forgot it needed to be a line trace…here ya go this should do it:
Spread is separated into a Min and Max here but it is basically the same concept as above.
I’ll leave this here incase someone else might need it too.
So I have not had the chance to try this out yet, but just looking at it brought up an important question. When you zoom in would you simply lower the value of the max spread to make the trace more accurate?
Correct, you would lower the spread amounts to make it more accurate.
So I did this and its working great, however I am having 1 final problem. When I shoot, the line traces are not completely centered on my center crosshair. The direction that they are shot away from my crosshair depends on the distance between my player and the object that I am shooting. I have attached two screenshots as examples of my problem. Would there be a way to make sure that the lines will spread, but always around the center? Rather than grouping up in different areas like they did here in my screenshot?
Think of it like a shotgun the further out the further the spread, that’s why I said it will work like a shotgun. Where are you running the trace from and what values do you have for the min and max spread? You can set the trace to start from the weapons muzzle instead of the camera to try to get better results. Your Min Spread should be a negative number and your Max Spread should be a positive number otherwise if they are both positive you are limiting the spread to 1/4 of the potential “coverage” of the blast.
Oh goodness, I was using both positive numbers. I fixed those values and also made the beginning of my line trace at my camera’s location rather than my camera manager location. Works perfectly! I have also set the values lower when I zoom in and it works flawlessly! Thanks so much! I very much appreciate the quick answers!