I am wanting to get some more information out of a line trace. Basically I would like every impact along a line trace. So a cube would have two impacts, one as it enters the cube and one as it leaves. A doughnut would have 4 impacts as it passes through.
Is there an easy way to get this information out? Or is there a better option than linetrace? Basically I would like all impact locations for all objects along a shotline.
FYI this is for modelling and simulation as opposed to gaming.
It seems you want the basic logic of using successive line traces and detecting the total number of hits in and out the body.
You may want to ckeck a feature equivalent to “simulated ballistics”, or “bullet physics” in which a series of coordinated line traces register all impacts hits of a bullet in order to simulate reallistic behavior, including: calculate the thickness of the penetrated body, calculate trajectory deviation or ricochets depending on the body material hardiness and hit angle.
If you search for this topic, you may find only a few tutorials or even few marketplace assets with this kind of gameplay mechanics.
Typically, there are no polys to hit on the “inside” of a mesh. You might try a specially crafted mesh that has polys inside it, and see if that works.
You might also try tracing twice, once from start to end, and once from end to start.
Thanks for your suggestions. I have tried a few things.
Firing a line trace back from the end location will give me the exit point but not any internal geometries. So it could be an option for a simplified version of the model.
I tried making a variable that is the line trace origin. The variable would be set to the impact location with each loop and the line trace run again. This sort of works but because the objects are solid it needs to have a step forward added every time step. The line trace passes back true when the origin of the line trace is inside the object. This makes the computation too long for my purposes. However this would work for internal geometries or for hollow objects.
It seems there are a lot of solutions for simple shapes, but as soon as complex internal geometries are involved it falls over a bit. I will keep working at it and if I find a solution I will update this post.
Sorry if I wasn’t clear, I have managed to get the line trace to pick up all the following objects through the first object. But I would like all the impacts on all objects. So any internal structures are also picked up as well as when it exits the object, not just a list of objects along the line path.
It seems a line trace only pings the first instance of impact on each object, not any others.
So you might say that you want to get the exit hit on the back faces of a mesh?
If that’s right, I think the simplest way is just dupliate your mesh, invert faces, and then could make that mesh set to not render.
Probably a programmatic way to do it but I reckon that would involve some real programming knowledge - probably require an expert with the engine.
edit: actually that may not work if it’s only reading one hit per component/object anyway. I am not sure that is the case or not. I guess you could test if you havne’t already.
May only be a difficult, expert-necessitated way to do it then.
A way, not sure if it’s the best way or not, but you could at least test, would be to create a Child Actor that is identical to the original Actor in every single way, but with it’s DrawScale set to -1, -1, -1.