Line Trace Mullty Camera

i have set up my bullet line trace to work with 3 types of camera.
As i have 1st person view, and player can switch to 3rd person with Left/Right shoulder

So i first do a line trace from the actual (Current) camera location to the (Crosshair) to World Location
Which is fine

  • The BLUE trace line is from the Camera

  • The purple is from the actual Gun Barrel point to the [END] of that previous line trace Hit Location

now my problems is, yes they both go to the same point, but the second line trace i think sometimes ends before the actual hit, and its not hitting/registering every time.


so i though to get the forward vector of the location hit and just (*2) but its going way of.
i tried with “Find Look At Rotation” from Start to end of line trace and then add the forward vector *2, still going way off .

How can i achieve this ?
Thanks

You already have the normal at the point of impact. *-1 points it the other way ( into the mesh ), and multiply it enough to get it to sink in.

1 Like

That sets off the second line trace result position way off, i need to add that extra +0.050 towards the Forward vector of the first Trace so the seconds Trace registers the hit

i have tried doing a “*-1” off the "Impact point, but it goes way off as it goes in the oposit direction as you said.

Or aim i doing it wrong, i just need to increase the forward vector of the hit result from the first line trace

NOTE: it is important that the second line trace registers as if i use the “camera” one to check a player can be peeking around a corner at it would register the hit, but the actual weapon will not

It sounds like you’re combining the result incorrectly.

Normal * -1 is very definitely the opposite vector. But you have to add it onto the end of the line trace.

You could also just make the line trace longer.

I’d spend some time figuring out why those traces aren’t hitting…

1 Like

yes its not hitting as the previous Trace would actually end just before the (actual] hit.

So after messing around i have worked it out but its a bit more of calculation.
I Simply Calculate what the Line Trace is doing and add 50 offset to the line like so:


The BP looks like so(had to put it in a Macro as it was becoming messy):

The actual Macro:

Now it registers and hits perfectly. if there is a better way of achieving this, please advise.
Thanks :slight_smile:

Ok, so the trace just wasn’t long enough? :slight_smile:

Yes, that’s why i had to re-calculate the reference from the First trace and add an Extra (50.0) to the length so the second Trace would “hit”

As using the End target from the first Trace impact point did not seem to always HIT.

If that makes sense

But why not just make the trace longer?

The first Trace from the camera is multiplied by “500000”

But if i run a single Trace from Weapons Barell Position to the Center screen 3D world space, i would get massive Offset in 3rd Person camera/s:


This is from the First Person View(closer as the weapon is actually pointing there)

So in order for me to solve that, i first run a trace from the the Current camera to the End point(Center screen) which is multiplied by “500000” originally

When that lines hits, it then Line traces the second line from the Berrel to the Hit position of the first.

thatch why the distance in the second line trace is short. i don’t know if there is another way to extend it rather then the one i just figured out.


hopefully that makes sense

made a small video if anyone is really interested of what im talking about :smiley:

I’m just checking. You know that red cross hair in not in the right place in the default first person?

Why not just run a trace from the screen center in both cases?

i know the cross hair is off centered by 20px higher, i have already calculate this from the Screen point to 3D Axis, no problem with that.

“Why not just run a trace from the screen center in both cases?”
Because if a player is peeking at a corner but realistically the weapon is behind Mesh/Collision it would still hit as the camera is about +60 offset to the right/left of the weapon

that’s why i need the second trace from the Actual Weapon Barrel/silencer point.