Line Trace Behaves Differently for Different Objects

I’ve been stuck on a problem for a while, and it actually took way more time than it should have for me to narrow the issue down to this, since it was so unexpected. I couldn’t find any answers online myself, though hope I’m not missing something. So here’s the thing:

I’ve casted a multi line trace from the right side of this image to the left side. It’s trace is gone here but it’s path was exactly the same as these red and blue lines. Now I’ve made it so that when this multi line trace gets a hit 2 times, a normal line trace gets casted from it’s hit location (that would be it’s 2nd hit location, which is the pillar on the left side of this image) to it’s start location. You see this first image of mine shows the expected result, the red line trace turns blue when it hits the pillar on the right side and a pink sphere gets drawn on it’s hit location. But that sometimes doesn’t work :sweat_smile: Take a look at this second image:

I’ve performed the same multi line trace on this one as well, it passed through the pillar on the right side and ended at the wall on the left side since it was it’s 2nd hit location. (Yes, there’s a wall there :rofl: I made it transparent to clearly show that there’s no red line inside it) With the logic I’ve explained, left half of this blue line across the image should have been red until it hits the pillar, right? But it seems like the normal line trace’s red part already starts at the hit location! (well that obviously can’t be possible but you know what I mean, it hits very close to the start location)

I suppose the only difference between these two scenarios is that I’ve imported these pillars from Blender, and this transparent wall is just a shape from the engine. Sure, their collisions might be different, I know these cubes also have a space diagonal as a collision line, it might be hitting some collisions from inside but that doesn’t make any sense! Like I said, the normal line trace that traces all the way backwards from the end location which is also the 2nd hit location of the multi line trace should already start on the outer side of any mesh, am I wrong? What matters should be their collision settings, which are exactly the same! To be honest, of course something must be different or I wouldn’t be facing this issue in the first place, but I can’t put my finger on it.

I hope there are some fellas whom I can get help from. So many thanks, all in advance! :blush:

(I accidentally posted this exact question as a discussion yesterday and wanted to correct it. From that previous posts, we did some troubleshooting with the help of @doctorpepperdan but unfortunately changing the objects’s type from static didn’t work :sob:)

1 Like

Does it work if the it’s not at an acute angle, a near right angle to the wall, for instance?

I’m wondering if the return journey starts from just inside the mesh.

If this is the case, you can circumvent the problem by following the inward trace back along the impact normal for a small distance, before starting the return trace.

I will definetly try that, and it will probably solve the issue. But I still wonder why do I face this issue in the first place, like I would love to learn how the engine views the situation. There aren’t any additional scripts running in the background so it should start the trace just at the surface of the hit object, and the part where I’m lost is that it does what I expect on some objects but doesn’t on others! Does anything comes to your mind on what tool can I use to debug further to understand this behavior of the line trace?

Oh almost forgot about your first question, no unfortunately, I tried casting the traces from various angles and the only clue I could find was that the normal line trace (that starts where the 2nd hit of multi line trace is) actually goes back if it starts on the surface of an object that I imported from Blender

The answer if to dramatically increase the amount of debug, until it becomes obvious what’s going on.

So, the start and impact points of course ( are they exactly where you would expect ). Also, drawing small meshes or debug shapes at various points.

Also, maybe take a look at the scene in player / visibility collision mode, and see if it is as expected.

Thanks for that! So I printed out the start and hit locations of the normal line trace and… they turn out to be exactly the same :rofl: how in world is that possible?? And you know what? That location is 100 units away from the object! What’s even going onnn :sob:

That’s the blueprint btw:

Just a normal looking, innocent blueprint :innocent:

1 Like

Did you check the collision view?

1 Like

I don’t know what to look for in that view mode. All the objects are just dyed to a cyan color and everything seems fine

1 Like

The issue totally gets solved when I start the cast a little bit away from the object’s surface (it was already starting 100 units away from the object and hitting something magically at the same location, and I adjusted it to move away only 1 unit more and it’s done) just like you said, but isn’t that such an unexpected outcome?

  • Like there are so many things wrong with this, you see my blueprint is so simple yet it doesn’t do what I expect on the objects I created from the engine, but it works just fine with the shapes I imported from Blender regardless of it’s shape wether it’s curved or flat.

  • The normal line trace doesn’t start where I’ve set it to be.

  • The trace hits something in completely empty space.

I’m really curious what’s causing all these, thank you so much for your help! I can move on with my project just fine, though I think something’s off with the engine don’t you think?

1 Like

Ok, we are just making sure the shapes are the same as you are expecting :slight_smile:

Can you show all the trace code?

There are some conditions here and there but I’ve already tried removing them, the outcome is the same. So all the functional stuff is in that image I’ve sent, it’s this:

1 Like

Ok, so you’re letting the engine manage the multi trace. That might have something to do with it.

I don’t know what the defaults are with regard to entering and exiting meshes are… :thinking:

1 Like

I wanna add something, even though it prints that the line trace is being casted 101 units away from the object (100 wasn’t about me but I manually added that 1 extra unit to push it away from the object) it doesn’t seem like it, it still seems like it’s being casted just from the surface. Well of course my eyes won’t be able to see that 1 unit gap but there’s definetly not a 100 unit gap there. I think it was starting the cast from inside and it was just trying to gaslight me :rofl: Boy we can’t even trust “print” debugging method these days

Yeah right? It seems like an engine related issue, maybe a bug. Maybe I should report? But I’m not sure if anybody would care :confused: There are literally bugs they haven’t patched for years

1 Like

It might be an interpretation issue, I’m not at a machine rn to check it out… :laughing:

1 Like