Attach To Nearest Socket

Hi, How would I go about attaching to a socket that is closest to my mesh.

What ive made is a spike pit and when the character falls on it, I want it to attach to one of the 6 sockets ive made. But I want it to select the closest socket.
Ive managed to attach it to a specific socket that I specify but I would like it to choose the closest one to the main char mesh. Thanks.

I tried doing it this way but it is not working at all. Any help would be cool.

Thanks

Ah I got it working. I needed to make the distance float < and set the number higher. not sure how vector translates into floats.

If anyone has a tidier way of doing it let me know as I’m new to all this stuff. Thanks

Here’s a more generic solution:

1 Like

thanks! that’s a lot cleaner