how can I constrain socket attached actor on y axis in blueprint

Hello I posted this about a week ago in the answer hub but haven’t gotten what I need to move past it yet so I hope it’s cool if I post here to sort of draw attention to my problem. I am sure it is simply a math issue that I am not grasping but any help would be massively appreciated.

For those who do not wish to follow the link I will copy/paste my post in answer hub below the link.

Hello. I am working on a carry system similar to Half-life and Deus Ex where pressing interact on an item in the world such as a crate attaches that item to a socket on the root bone of my first person player skeleton. My problem is that I would like for the item to lift up and down when i aim up and down but without curving towards me as I do so. I am not quite sure how to explain this better so I am attaching an image to better express my difficulties. I was initially using no socket and using the teleport method for attaching the actor and positioning it however I found that this introduced a lot of bugs and weirdness to work around so I decided to do this with a two step process of attaching the item to a socket on my root bone and then using the teleport method to keep the item oriented in the viewport (if this isn’t making any sense hopefully the screen grab I post of the relevant bit of graph will help explain) This works superbly for keeping the item oriented for my player but not so much for the axis constraint.

I have tried as number of things but nothing seems to work. I feel like this should be something pretty simple and I am sure that it is and I am just missing it somehow but I just can’t seem to come to a solution for this on my own.

You will notice in the blueprint there is no attempt to constrain the item at all. This is simply because everything I have tried has failed and as such been removed. I am hoping to get some better ideas here.

By the way the red crosshair in the image represents the socket on my skeletal mesh.

A Huge thanks and endless gratitude goes to whoever can help me reel this issue in.

Well there’s a lot of ways to go about doing this.

One way is to stick an arbitrary point (maybe use an Arrow that’s pointing up/down) out in front of your actor that will be used as the reference axis for your grabbed actor. The X and Y position of this arrow in world space(1) you’ll have to give to the grabbed actor every frame while you’re holding it. That will keep it a set distance in front of you. Now you have to move it up and down when your player looks up and down. Now you have to use your look vector to calculate a triangle using the pitch of your look angle and the distance from the Arrow to your looking mechanism (your camera)(2). Once you figure out the height of that triangle, either negative or positive, that should be the relative height of your grabbed actor to your actor. You’ll have to transform that to world space as well, and then set the calculated X, Y, and Z as the location of the grabbed actor.

(1) To get the world position of a component, use Get Actor Transform (if you’re in 4.5 you may need to switch the context menu off) and plug that into Transform Location along with the relative location where you want to place the actor. So that means build a vector with the calculated X, Y, and Zs and plug that into Transform Location.

(2) You’ll need to use trigonometry to calculate the sides of a triangle and find your Z position for your object. Draw it out and google is your friend.

Sigh Trig… I knew I should have paid more attention in math class XD

Thanks Cobryis for the input. You have certainly given me some things to think about. I will admit I am not quite there yet so any further elaboration would be monumentally helpful but I am certainly going to be experimenting with what you have given me already.

you can use something like this