Third Person Shooting - traces and math?

Hi, ill take this briefly:

PROBLEM 1: Is there simple solution how to get more impact points with trace on same object? Or i need to use more traces? In my case i will need at least 5 so i wanted to avoid this


PROBLEM 2: Im using trace impact points to determine rotation for spawning projectile… Simply put - where i look, there i shoot. But problem occurs when i determine bad impact point - then i shoot behind myself what is pretty BAD. So im using multi trace to determine more points.
I need some kind of math to determine if i shoot in front of myself… Any ideas how to calculate or how to detect if impact point is in front of gun and not backwards?

Note: black pillars are walls, in my game i can see through walls if im near them


Any help is appreciated. I can OFC blueprint this behavior but need only tip how to do it, i spent with this over 20 hours unsuccessfully so im totally tired at this moment…

I’ve put some thought into it and there are definitely some challenges that you could run into with making a 3rd person shooter in the way that you are suggesting, but that’s really the only way I can see it being done. I would like to see how Epic dealt with these challenges in Gears of War. For example, where does your character aim the weapon when you’re looking into the sky and the line trace is hitting nothing?

Anyway, the solution to your first problem is to perform two line traces, with the second going in the opposite direction.

Here is a quick and dirty solution to your second problem:

What the above code is doing is shooting out a multi-line trace from the center of the camera, looping through all of the hits while ignoring any hits behind the player, and then finding the nearest hit and setting that as the target.

Hi, thanks for tip :slight_smile: yesterday i solved this but it was so unpolished so i wanted to post it today.

Basically i solved both problems with one code:

I shot single sphere trace. If it hit something and DOT product is negative (it means character forward vector and findlookatrotation from muzzle to impact -> forward vector… im comparing these two forward vectors to determine negative or positive value so this is solution for my 2nd problem)

Then

Im getting time of trace - its length, then i multiply time with trace length and add small value for example 50 and i add this length to trace loop so every bad hit it generate new trace, with this i avoid doing many traces, usually it can do 2-5 traces when i find good point :slight_smile:

Works pretty well but need some little polish :slight_smile: so i think multiple fired single traces + dot product are necessaries for this… im really satysfied with results, it took me ±30 hours to do this.

If someone wants to see bp script, just quote me (ill get notifcation) and when ill be available i can post screen.