If actor have multiple sockets, can i tell the name o f the closest one to a player? Or somehow by raytrace when i look at the side with socket on it?
Hello, TomaszuJerky,
In case you still need it, you can use a “Get All Socket Names” node to get an array to all the sockets in a skeletal mesh. Save it in a names array called socket names. Then you do a for each loop on that array, and use the “Get socket location” node to get the 3D world coordinates for that socket. You then substract that location from your player’s location, and get the length on the resulting vector. Save that in a new float array named socket distances. Do this for all the socket names.
At the end of the for each, get your socket distances array and run it through a “Min Of Float Array” node. That will give you both the index and the value of the lowest distance saved in your array. Now, take that index value and use it to get an element of the socket names array with the same index.
That will give you the name of the closest socket to the player. You can then display it any way you want. You can even get the socket’s location again to display it hovering over the socket or something similar.
If you want to do this with a trace, this outlined method will work but you will use the hit location instead of the players location to get the length. Everything else remains the same.
Also, if you wanted to do this with bones, it is much easier because there is a “Find Closest Bone” node that you can use and does all the heavy lifting. It takes a skeletal mesh target and a 3D location as inputs, and returns the bone name and its location too. Again, you can use either the player’s location or the hit location as inputs.
Hope this helps someone. All the best.