x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How could I create weapon spread via a line trace?

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!

Product Version: UE 4.10
Tags:
more ▼

asked Mar 22 '16 at 09:10 PM in Blueprint Scripting

avatar image

Anaklosmos
170 35 29 54

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Opps forgot it needed to be a line trace...here ya go this should do it:

alt text

Spread is separated into a Min and Max here but it is basically the same concept as above.

more ▼

answered Mar 22 '16 at 10:08 PM

avatar image

Black Phoenyx
4.1k 165 9 170

avatar image Anaklosmos Mar 24 '16 at 09:46 PM

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?

avatar image Black Phoenyx Mar 24 '16 at 09:54 PM

Correct, you would lower the spread amounts to make it more accurate.

avatar image Anaklosmos Mar 25 '16 at 12:57 AM

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?

alt text

alt text

untitled-2.png (608.6 kB)
untitled-3.png (578.2 kB)
avatar image Black Phoenyx Mar 25 '16 at 01:20 AM

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.

avatar image Anaklosmos Mar 25 '16 at 02:49 AM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Try something like this:

alt text

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).

more ▼

answered Mar 22 '16 at 10:02 PM

avatar image

Black Phoenyx
4.1k 165 9 170

avatar image Black Phoenyx Mar 22 '16 at 10:09 PM

I'll leave this here incase someone else might need it too.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question