Hopefully this is an easy solution, I just need help understanding this concept.
I have a static mesh who’s zero pivot point is very far off from where the actual mesh is. I have to keep this offset as the offset is actually part of a bigger CAD model. I created a socket where the actual mesh is, so I have a location as to where I want to attach to later.
When attaching this static mesh to an attachment point (scene component) on another Actor, I’m having a difficult time understanding how to set the static mesh (again pivot point is very far from where actual mesh is) where the X axis of the socket will line up exactly with the X axis of the attachment point (scene component).
I know that I need to rotate the mesh to compensate for the rotational offset between the socket and the scene component, but I don’t know exactly how to do that.
I’ve tried simply getting the delta rotator between socket and attachment point and subtracting that offset from the static mesh rotator but that does not work. Here’s the logic for the rotator. From this I just set the world rotation of the static mesh:
Also, I attach static mesh to scene component with “Keep World” for location, rotation, and scale:

Drill Scene Component:
Part attachment socket:
Any help would be appreciated!
To add to this, I only care that the Yaw and Pitch of the socket matches the Yaw and Pitch of the Scene Component. The Roll does not matter. I guess taking 1 plane out of the equation might make the math simpler.
So I found a way to algin the Parent rotator to the component rotator. Pretty simple, you just get the delta rotator between the two and subtract the float values and make a rotator. I’ll upgrade this to a Quat at some point, but this puts the forward vector of the parent and scene component to be equal.
The only problem I’m running into now is how do I calculate the rotator that I need to set on the Parent component so that the socket rotator can match up with the scene component’s forward vector. I feel like dot products are going to need to be involved but I just can’t see how all of these concepts fit in to build up a rotator that I can then set on the parent to line up the socket forward vector and the scene component forward vector.
I finally figured it out! Quats were the way to go. I can simply use the “Find Quat Between Normals” function using the forward vectors for both parent and socket (for socket you have to get forward vector from world rotator). Cleaned up the first bit of code as well and this is the final result:
First Add World rotation is used to align the forward vectors of the parent and the component rotator. Once those are aligned, then you add another rotation based on on the offset of the forward vectors of the parent and socket. Doing two Add World Rotations like this gives me exactly the result I want!
If anyone can think of a different way so you only add world rotation once that’d be great but honestly, I’m glad it works perfectly.
I couldn’t help myself, I found a way to calculate the world rotation required to get what I want and it’s pretty simple. Here’s the code:

Remember the socket is a child of the “Attached Ref” and we’re trying to make the rotator of this socket match up exactly with the rotator of the “Part attachment Point” or the third component. This also only works because I designed the Part Attachment point and the socket to have the Forward vector (or Positive X axis) to line up. So if I make sure they both point in the direction I want and then this code works wonderfully.
Alright I think I can finally put this to rest…