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"

LineTrace for Gun not working in sky?

Hello! My LineTrace for my gun works fine. It's just that when I shoot in the sky, the bullet just doesn't go anywhere. It just disappears and hits my body. How may I fix this issue? Thanks!

Here are my blueprints and the video showing the issue: https://youtu.be/j3ekn05jUTk Cheers!

Product Version: UE 4.21
more ▼

asked Jan 14 '19 at 12:48 AM in Blueprint Scripting

avatar image

115 2 3 12

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

0 answers: sort voted first

i imagine that your issue is the result of there not being a hit. without a hit you have no hit location and therefore any vector you set based on the hit location will not be correct (it should actually revert to a default location usually 0,0,0). im not exactly sure what you want to happen when you shoot at the sky since all your doing is spawning a actor and a sound at the hit location. i would add in a branch which makes sure there was a hit, to prevent the rest of the script from functioning when there was no hit. basically just add a branch after the line trace and connect the return value of the trace to the bool input on the branch. then connect your script to the true pin.

more ▼

answered Jan 14 '19 at 02:53 AM

avatar image

10.1k 33 9 23

avatar image CODE REDBALLG Jan 14 '19 at 05:03 AM

Thank you for the response. I want to make it that if the bullet doesn’t hit anything that the bullet will travel until 15 seconds then destroy itself. Is there anyway to do that? Also if that doesn’t work, is it possible to put a geometry high in the sky that the line trace can get a hit location from? Can i do this with a transparent geometry or mesh. If so how?

avatar image Tuerer Jan 14 '19 at 08:25 AM

If there's no hit, just manually set the trace end point to the end of your trace vector. You'll have a point somewhere in the sky without any additional geometry.

avatar image ThompsonN13 Jan 14 '19 at 02:33 PM

it seems like your combining two different methodologies for your shooting. using a line trace to search for hits and having noise and decal spawn at hit location is one method. this method is good when you need fast moving bullets that dont need to be seen. spawning a bullet actor and having it move and on hit do something is a second method.this method is good for when you want to be able to see the bullet moving through the air. youve chosen to combine these methods which will not work well (im surprised it works at all). the problem with your setup is that your spawning in the projectile at the hit location, so the projectile is "invisible" until the hit location then becomes visible when its spawned and while its hitting a wall.

but again its your system to work with so do what you like. if you want your current system to work as you say then do what tuerer mentioned and if theres no hit then use the trace end location instead. also to have your bullet last for 15 seconds set its lifespan (i think thats the right word dont have ue4 open atm). the lifespan basically just says that the actor will exist for X seconds then will be destroyed, so a lifespan of 15 means the actor will spawn and 15 seconds later will be destroyed.

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

Thank you for the response. Is it ok if you can show me an example blueprint for the first method.

avatar image ThompsonN13 Jan 16 '19 at 01:05 AM

below is basic examples of the two methods i mentioned in the previous post.

the first picture shows an example of fast moving bullets like you would see from a rifle (i would think cod as an example). here you are basically just doing a trace between two points and applying damage to whatever actor is hit. do note the branch just after the trace which controls whether the rest of the script runs depending on if there was a hit. i also added in some conditional sounds, particles, and decal depending on the collision of the hit object (pawn or inanimate object).

the second picture shows an example for slower moving projectiles that you would see moving through the air such as a rpg or nerf dart gun. note the picture shows the graphs of two seperate actors. the left section is what would be in the gun actor or in the character depending on how your handling firing the weapon. in this section you call the fire weapon event (rocketShot) then you spawn the projectile. the right section is the projectile itself and where most of the behavior happens. here you have the projectile movement component where you can set the velocity of the projectile (details panel) and some of its behavior. also this is where you handle the hit/collision behavior, for example here i have on hit apply damage to the actor that wee hit, then spawn a fire particle system and spawn a explosion sound, then destroy self. as you can see most of the behavior is in the projectile so the gun just need to spawn and thats it. of course if this were a real rocket you would want to add in radial damage and apply force to the hit actor, but we show the basic idea.

oh and the initial life span is what i was talking about in the other post. it can be found in the class defaults under the actor section.

alt text

alt text

capture.png (416.3 kB)
capture1.png (386.3 kB)
avatar image CODE REDBALLG Jan 16 '19 at 04:05 PM

Ok! Thank you so much for this! I just have two quick questions. 1. For the rocket example, would I need a need a line trace or did you just not show a line trace and I should use the line trace from the first picture. 2. I have a bullet actor that spawns from the gun to the end line trace. Should I use that one instead or use the Decal? Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Be the first one to answer this question
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