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: Ue4 LineTrace Error - YouTube
Cheers!

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?

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.

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.

1 Like

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.

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

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.

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!