Seems like I skipped your post, my bad.
If I understood it correctly, your “end” bone is where the hand bone would normally be, so your skeleton is:
which is the same as
(Epic’s skeleton, just with different names)
So if you’re attaching the gun to the “end” bone (or to a socket on the “end” bone) and replacing the references to “hand_r” with references to “end” in the code, then alignment should be working normally. This way, the “end” bone would already be the IK effector, and that is enough, yes. (Unless I didn’t understand your setup)
In my test the IK worked from hand to forearm, while the upperarm would keep in place. It looked fine, but the gun wouldn’t get to it’s place in front of the camera, because with only hand and forearm moving, it doesn’t have enough reach. That’s why I’m saying it wasn’t a problem with the IK, it was working like it’s supposed to, it was a skeleton problem…