x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 :(

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

Product Version: UE 4.16
Tags:
more ▼

asked Jul 30 '17 at 11:04 PM in Blueprint Scripting

avatar image

Kukuschi
1 1 2 2

avatar image Kukuschi Jul 30 '17 at 11:35 PM

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

avatar image ipninichuck Jul 31 '17 at 11:40 AM

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.

https://answers.unrealengine.com/questions/481328/how-to-determine-a-cubes-rightleftetc-through-line.html

avatar image Kukuschi Aug 01 '17 at 12:00 PM

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.

avatar image Andrei Branescu Mar 29 '18 at 12:50 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Mar 29 '18 at 01:28 PM

avatar image

Velrin
375 2 10 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question