Attaching Object to Mouse?

I’ve trying to make something similar to what they have in Kerbal Space Program. I would like to attach the object, to the the mouse and have it follow until I snap it to something.
I’ve uploaded a little clip onto youtube.
Any advice would be greatly appreciated.

Thank you!

I would get my mouse position and use the Deproject Screen to World node. That gives you your world location and direction, which you can multiply by a length to move it away from the camera.

For snapping, I’d have a sphere volume around the snapping point of the currently held object. If a snapping point of another object has begun to overlap, then snap the objects together.

Thanks for your reply! I think I’m picking up, what you’re putting down.
I’ve been testing a similar method using LineTrace, but there is a lot of lag. Kerbal Space Dev seems to have done something a lot more creative. LoL. There is very little lag in the video.
I will try Deproject tomorrow.

While I have your attention… :slight_smile: any thoughts on dynamic duct tape?
https://forums.unrealengine.com/development-discussion/content-creation/1630901-ideas-for-creating-dynamic-duct-tape

I’m collecting ideas. XD

Thanks Again!

Yup, just sent over my 2c on that page.
I haven’t really worked too much on getting mouse locations, but when I did it getting an accurate position was a pain in my ■■■ due to dpi, rescaled windows, and such. Just be wary of that.

I think that what you want is “Get hit result under cursor” then for every tick set the dragged object position to the hit location and check if it is something you can actually attach to.

The “Top down” game example provided in engine implements this for a custom cursor.

This is what I ended up doing.
Thank you :slight_smile:

That works for detecting which object to snap to, however if you wanted to add in stuff such as a ghosted object for visualizing placement like KSP does you’d want the information that the “Deproject Screen to World” node gives.