LineTraceMulti "exit" hits

LineTraceMulti finds only “entry” points. I’ve created a bullet system, it’s actually cool, because each bullet isn’t an actor, it’s custom classes, that “optimized to death”. These classes uses LineTraceMulti to find entries and exits. Bullet will be slowed down by drag inside collder. Distance between entry and exit is distance inside collider, but as i admitted it finds only entries.
How to find entries and exits in one LineTrace? Maybe i can somehow modify engine, so it will find me exit hits? (The code with LineTraceMulti looks strange actually, it always just returns false) I just don’t want to use most ineffective way - tracing from start to end and from end to start, then sorting it… Sounds very slow for 1000 (and below) calculations per/frame.

Well, i’ve created algorithm for “most ineffective way” pretty good. It took me 40 minutes, what is pretty fast for me. Sorting by X coordinate, expecting that X for impact points will never be the same (even if it will be so, it will only make miscalculations in distance traveled). Code works flawlessly. Need to test with thousands of bullets…

You could do a line trace multi in the opposite direction until you hit the collider to figure out the exit point.

E.g. suppose for simplicity we only work in the XY-plane, and the collider is a cylinder. Now, you’ve traced and hit this cylinder. The maximum length the bullet will spend in the collider is the collider cylinder’s radius. So, if you keep moving r units along the bullet path, you’ll be outside of the cylinder. Now you can trace back in the inverse bullet direction until you hit the cylinder again - this will be the exit point.

Distance traveled in cylinder maybe longer than R if we hit it from corner of base to center, so this distance not always R. I’d already figured it out. I made two Line Traces, then created array of pointers to elements of these two arrays, sorted it by distance and Yay! But it caused this: Memory Hell

Yeah, that’s why I said for simplicity let’s just consider the XY-plane. Technically, the max distance in a cylinder would be sqrt(r^2 + h^2). A capsule would most likely be just h - but that could change if the radius is larger than the height.