Dragging meshes with mouse

Hi there,

I would like to make a “system” that would allow player to drag the objects around. Right now I managed to make it so that I can drag a cube but the problem is that when I click on it, it jumps from its current position right into the camera.
I am aiming to make something like on this video: UE4 Rigid Body Interactions with Mouse Interface - YouTube
It is also important for me to make sure that the object is dragged exactly by the point where you click with the mouse cursor.
Here is the screenshot of my blueprint

Hope for your help guys

An update - I am trying to cast to Player controller from FirstPersonCharacter BP to set the Trace distance. But can’t do it. I need to make the game calculate the distance from the camera to the object, depending on hit result of the line trace. Then I want this distance to be a float value for the Trace distance in the Player controller BP.
In other words I want the character to come near the object and drag it from its place without the object jumping out of its position.

To calculate the distance you should just be able to subtract Location of your hit result from you camera location and get its absolute value. If you right click on the yellow vector pin you can break it to get the float values of each axis. Seems the X values may be the only value you need since you are checking straight line in front of camera relative to the crosshairs.

I already tried it. It just doesn’t work its way to “SET” node.

Try printing the values of both your camera location and the location coming from the Hit Result to see what values are coming out.

Also, “Get World Location” may not be the function you need because, if I’m not mistaken, the Trace returns a relative location. Try using the “Get Actor Location” from your First Person Camera and see what that value is also in a print string.

You should also get the Absolute value of your result. Between where you plug the X of the Break Vector into the Set node, put in an Absolute node. This will return a positive value which is what you’ll want (when you get it working) to get better/easier calculations with it. That way you won’t have to wonder every time you trace, if it’s giving you a positive or negative number because that will make a difference in how you calculate with your “Hit Result Trace Distance” variable down the road.

It doesn’t work, and you can’t get Actor Location node from the camera.