Can "Line Trace By Channel" detect when I exit an object?

Hi!

Apologies if this is the wrong subforum or if this question was already asked somewhere, this is my first post and I couldn’t find any other threads related to this.
I am using Blueprints and the “Line Trace By Channel” node. Everything works perfectly fine, except when the line trace starts inside an object. I would like to know where I exit the object. As far as I can tell, “Line Trace By Channel” ignores this case. Am I doing something wrong or is there a way of checking for this?

Thanks a lot in advance!

1 Like

I don’t think you can trace from inside an object.

Can you explain your case a bit more?

Thanks for the quick reply!
I have a “laser beam” that I would like to have three cases for:

  1. Reflect on certain materials (array of material interface object references)
  2. Refract when entering + exiting translucent materials
  3. Do nothing with all the other materials
    I got everything to work except 2.
    When I start outside a glas cube, I can get the hit onto the glass cube, but when I then add the refracted beam that starts within the glass cube, I don’t know how to get the point where the glass cube ends. I was hoping I could just do it with another line trace, but as I’ve discovered, I don’t get a hit.

Edit: As a workaround, I’ve made all my glass objects to be only thin walls of glass instead of being “fillled”, such that I can refract on the thin glass panes instead and get a hit when I hit the other glass panes when “exiting” the glass objects. But that, of course, requires me to manually “empty” all glass objects.

I’m thinking you could go one of two ways:

  1. You know how you’re going to make the trace inside the object, so you can imagine extending that ( a lot ), and then doing a line trace on the reverse of that vector. There’s your hit point

  2. Do a multi sphere trace with a very small sphere, and wait until you get the first exit sphere.

I think the line one is better. You will always have the problem that it may not work for unpredictably large objects, but I could live with that.

1 Like

Thanks!
So I basically just extend the beam until I am sure, that I am outside the glass object and then do a trace in the opposite direction? Doesn’t this cause problems, if there are objects in the way, because the line trace will hit those first? Or did I misunderstand something?

Your beam inside the object needs to be long enough to exit most objects.

Then, reverse that trace, but do a multi-line trace and keep going until you hit the same object.

Yes, it could be expensive, but then so is translucency :smiley:

Or, yes, you could stop on hitting another object, of course…

1 Like

You could also maybe trace for objects of that type on an interval that won’t over load your CPU then run through a for each loop and only when true on those objects withing a certain vicinity you can do all that laser beam stuff relatively effectively without running many line traces every frame.

Ah, I understand! Thank you so much :slight_smile:

Good idea! I’ll keep this in mind. Thanks!

1 Like

Be interested to see the results! :slight_smile:


Not super pretty right now, but it works :slight_smile:
Thanks again for the help!

1 Like

Excellent :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.