How to receive whether line trace hits backface or frontface?

Hello,

i need to know whether a line trace hits a backface or a frontface (trace complex, mesh uses complex collision as simple and is double sided) but found no solution to the problem*. The only workaround i can think of at the moment would be to have two versions of the mesh, both not double sided and one with flipped normals. That would nearly double the meshes in the game :frowning:

I would highly prefer a solution with blueprints, but if everything’s falling apart i would be thankful about ideas or solutions involving c++, too shudder


first i thought impact normal and impact point would be helpful… but unfortunately they are what they say they are: impact normal and trace normal and not the normal of the hitten face

As a additional question concerning the workaround: Is it possible to flip all faces of a mesh via blueprint?

I am not sure if this will solve your particular case, but it might put you on the right track. I found this answer to a similar question regarding finding the exact direction a line trace hit a target.

That is a solution i thought of, too, but it does not work that way as far as i can see. The reason is, that the impact normal does not consider the normal of the face hitten (then it would be possible) but the normal of the hit point on the face. In case of hitting a frontface, it should be the same as the face normal. But in case of hitting the same face from the backfaceside it is opposite to the face normal: Both would have the same direction towards the trace starting point and so comparing them to recognize if a front- or a backface was hitten does not work. At least that is my understanding of it at this point.

You can do it, just like you said. The only thing to consider is that the normal of the face is fixed, perpendicular to the face, but the other normal, can hit at whatever angle.
What is important is whether the hit normal is on the same side of the face as face normal. The exact angle doesn’t really matter.
I think you can project the hit normal vector onto the face normal vector and see if the result is negative or positive. Not sure, though.

If you know the normal of the mesh your hitting then you can use a dot product check to determine if you are hitting the back side or the front side.

Do a dot product between the normal of the surface that you’re hitting and the direction of the line trace. If the return value is less than 0 then you are hitting the front face and if its greater than zero then you are hitting the back face.