Doing a line trace from location A to location B doesn’t always get you the closest point between 2 objects. I need a way to get the closest point between a location and a mesh.

This is what a line trace does.

I need something more like this

Doing a line trace from location A to location B doesn’t always get you the closest point between 2 objects. I need a way to get the closest point between a location and a mesh.

This is what a line trace does.

I need something more like this

There could be multiply ways to go about this. Can you please show us some of your work and/or supply more detail about more specifically what you are trying to accomplish and why.

Like I said in my original post, I need to find the closest point between a location and a mesh. If I can get the closest point, then I’ll be able to calculate the actual distance between a location and a mesh (instead of the distance between actor location and actor location). I first tried this with a sphere trace, but the problem with that is that it doesn’t give an accurate hit location if the sphere trace is overlapping the mesh from the start.

I’m not sure I understand from those pictures above, why isn’t the line trace working, could you give a more detailed explanation?

If I do a line trace from Location (yellow dot) to the mesh’s location (green dot), the trace’s hit location will be where the red dot is, which is not the closest point on the mesh to the Location (yellow dot). The blue dot is the closest point on the mesh to the Location (yellow dot). I’m trying to figure out how to get the closest point (blue dot) in blueprints. The method I use needs to be able to work with meshes of all shapes and sizes.

I would just use Rama’s BP library which has a BP node for this exact thing

This is exactly what I’m wondering. It seems to me you know where the actor is located so here’s an idea…

Get the distance between mesh and actor. Draw a line trace in a star pattern from the mesh (EG two letter “X” overlapping by 90 degrees). Whichever hits the shortest could be assumed the shortest distance from mesh to actor. There will be some variance depending on angle but overall will be fairly close. But, if you told us why you wanted to find the closest point perhaps we could help you with a better solution. Reasons matter.

I’m very interested in this as well, and would need it so that I can trace to that point on the mesh for normal calculations of that closest point… but don’t aim to hijack this thread, I hope his question can get answered.

My silly solution was to send out a bunch of traces in semi-logical directions and the trace with the shortest distance (break the hit and calculate distance from the source location and hit location) is the closest. You could then from there shoot out a new bunch towards that same point for a better/closer hit. It’s not nice at all, so I hope this thread will come up with a better solution.

He might be trying to do what I was looking at a long time ago:

Home made collision hit return data

Basically extract data from a trace to the closest point on a mesh (which you can’t get without physics/collision hit event afaik). Our images look very similar anyway, but he might have other reasons. In my case I was just looking for the normal of the mesh at the closest point.

Thanks for the reply. I’ve already told you why. I need to find the distance between the Location (yellow dot in the picture above) and the closest point (blue dot), but before I can do that, I need to figure out how to find the closest point on a mesh to a location (yellow dot).

The third post in your thread is a great diagram of what I want. I’m not looking for the normal however. I just want the world location of the point on a mesh that is closest to another world location.

Which node are you talking about? All I see is the Closest Point to Source Point node, which is not what I’m looking for.

Should be closest point between surfaces node or something along those lines (I’m not thinking of the closest to source point, for sure).

Thanks. Yeah that node worked perfectly. However I realized I’m an idiot. There is a node built into the engine called Get Closest Point on Collision, which does the exact same thing as Rama’s BP function. I don’t know how I missed it earlier when I was researching how to do this.

All these solutions seem to apply to physics objects. Is there a way to not use physics and get the same data - closest point on overlap let’s say?

My method works with physics objects and static mehses. If it is a static mesh, just leave the bone parameter as “none”.

Where’s this Rama BP library?

Thanks for finding this! It took me a while to reach this point as well. This worked perfectly for me!

There’s a node on the Static Mesh called “Get close point on collision”, which can find the point on a model that is closest to this point. If you want to find the two points that are closest to each other on two models, such as objects A and B, you need to use the actor location of A to find the closest point on model B, and then use the actor location of B to find the point on A that is closest. These two points are the closest points on these two objects. Of course, the center of the actor is not necessarily the center of the model. A more rigorous approach would be to obtain the model boundary and calculate the center point.