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"

Why do my shotgun shells spread further as I go further?

Hello Community! I have made a shotgun system where it fires 11 shotgun shells. I have made it using this code.

https://answers.unrealengine.com/storage/attachments/236628-screenshot-2018-04-07-164441.png

It works fine it’s just that the further I go, the wider the spread gets. Is there any way to get the spread to always stay he same size? Thanks! Also I have a question about line tracing. Which one is better for guns. Line trace by object or line trace by channel. What are the pros and cons. Thanks!

Product Version: UE 4.21
Tags:
more ▼

asked Jan 15 '19 at 02:12 AM in Blueprint Scripting

avatar image

CODE REDBALLG
115 2 3 10

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

you could use two groups of line traces the first group which shoots out from the gun and spreads, then the next group uses the end points of the first group as it's start position. Then the end position is just the shotgun's forward vector * range(float) + start position.

Alternatively you could just shoot a single sphere trace, but you wouldn't be able to do partial hits very easily.

Not sure about pros and cons, I would probably just go with line trace by channel visibility until I run into a situation where that won't work.

more ▼

answered Jan 15 '19 at 03:26 AM

avatar image

IndieGameCove
1k 5 4 10

avatar image CODE REDBALLG Jan 15 '19 at 03:36 AM

Is it ok if you can show me an example blueprint. I understand what you mean but I am just wondering how to do the second part. Thanks!

avatar image IndieGameCove Jan 15 '19 at 04:12 AM

sure, here you go. alt text

shotgun.png (150.0 kB)
avatar image CODE REDBALLG Jan 15 '19 at 04:20 AM

Thanks! Your help is appreciated!

avatar image CODE REDBALLG Jan 15 '19 at 04:23 AM

Wait where is arrow?

avatar image IndieGameCove Jan 15 '19 at 04:57 AM

I was just using an arrow component as the tip of my gun, it's useful for visualization purposes. The "projectile spawn loc 2right" in the pic of your bp is probably the scene component you will be using.

avatar image CODE REDBALLG Jan 15 '19 at 05:18 AM

Hello! I did what you said but this happens: https://youtu.be/rkR9yX7yRI4

avatar image IndieGameCove Jan 15 '19 at 05:46 AM

that's odd, im not sure what's going on. in the arrow component detail pane there is check box called "hidden in game" if you uncheck it you can see what the arrow is doing as you move around.

avatar image CODE REDBALLG Jan 15 '19 at 06:09 AM

The arrow is staying perfectly in place.

avatar image IndieGameCove Jan 15 '19 at 06:24 AM

you are adding where you need to multiply

forward vector x 1000

avatar image CODE REDBALLG Jan 15 '19 at 04:08 PM

Ok Thank you. I will try this later in the day.

avatar image CODE REDBALLG Jan 16 '19 at 12:48 AM

I did but it still doesn't work.

avatar image IndieGameCove Jan 16 '19 at 02:54 AM

I guess you could use the forward vector from the camera like you are for the the first group of line traces.

avatar image CODE REDBALLG Jan 16 '19 at 03:57 PM

Alright, will try later in the day

avatar image CODE REDBALLG Jan 18 '19 at 04:29 AM

It works but It goes through certain walls. If I go too close, the line trace appears on the other side.

avatar image IndieGameCove Jan 18 '19 at 05:50 AM

you'll need a branch node after the first line trace just to check if you hit something. If the return value is false then run the second trace. If true apply damage but don't run the second line trace.

Wouldn't hurt to put a branch after the second line trace either, since you don't need to execute apply damage when miss.

avatar image CODE REDBALLG Jan 18 '19 at 04:10 PM

Alright will do

avatar image CODE REDBALLG Jan 22 '19 at 01:48 AM

Ya that still doesn’t work. What should I do now?

avatar image IndieGameCove Jan 24 '19 at 12:15 PM

if the linetrace is going through wall then check the collision settings of the walls. if the gun is going through walls you could widen the collision capsule around the player.

avatar image CODE REDBALLG Jan 24 '19 at 04:19 PM

Thanks for the help! I figured it up, you have to put the Trace Start into the Start pin instead of Trace End in the start pin.

(comments are locked)
10|2000 characters needed characters left
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