So I have been playing with the thirdperson template and added quite a few things.
But there’s one thing I couldn’t figure out how to fix, which is Shooting Projectile while Aiming at the sky.
I have recorded a short clip demonstrating the issue I am facing,
Did you ever find a solution to this I am having the same issue and can’t seem to get it figured out…there must be something causing it to redirect to location 0 0 0. Something I did as a semi work around was set a different spawn if the hit result bool is false so the projectile will just fire in the direction that the weapon socket is pointed in but that takes away some of the functionality that I wanted to achieve with the line trace.
This was 7 months ago, nobody tried to help so I kinda gave up on it and settled with spawning projectile forward when line trace return false.
But I just thought of a workaround while typing this reply. You can try to create a large invisible box the encapsulate the level and set the line trace distance to be long enough to reach it. Let me know if it works
If the trace fails to hit an object within the accuracy range it will get the last reachable point of the trace (500000 unit out) and then get the X axis for the projectile to align with, this way objects that are very close still get hit in the center of crosshairs and further out it maintains most of the accuracy (full accuracy out to 500000 units slightly degrading after) everything after the “SpawnActor” node has to do with the sounds and emitters etc for the muzzle. If the trace hit is true it will point the X axis of the projectile towards center of crosshairs since the closer the object the closer the intersection of the 2 points becomes…at further distances the points are closer together…if the trace-end doesn’t hit something for some reason the spawn will give it a X axis pointed toward world location 0 0 0 so this is the way I got around that.
I hope that makes sense, it also keeps everything within the projectile spawning functions short and simple with out adding giant actors to scene.
Video Demo
This video show the difference between using the branch and not using it, using it give us the extra spawnactor node that will get the X axis of the last reachable point of the trace to use in the spawn transform of the projectile if the line trace doesn’t actually hit something. I hope it helps clarify what I am talking about. The way I am doing it works but I was looking for possibly better solutions, which is why I asked you what your solution was if any. Let me know if you need more info also if I find a better way of doing this I will make sure to post it here for you.
In your case you can use the location for the “End” pin of the trace for the last reachable point (“Max Accuracy Range” in my screen shot) and then use the “Projectile Spawn Z Offset” vector variable (the “Barrel Mesh - Socket location” from screen shot) Subtract the “End” pin for your “Z Offset” variable then from there a “Make Rot from X” node to the “Make Transform” node of the “False” pin SpawnActor and use the “End” pin location for the spawn actor transform location and that should fix it for you. Let me know if that works