Announcement

Collapse
No announcement yet.

Attaching Object to Mouse?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!




    #2
    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.

    Comment


      #3
      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.. any thoughts on dynamic duct tape?
      https://forums.unrealengine.com/deve...amic-duct-tape

      I'm collecting ideas. XD

      Thanks Again!
      Last edited by NfrancisJ; 06-20-2019, 03:19 AM.

      Comment


        #4
        Originally posted by NfrancisJ View Post
        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.. any thoughts on dynamic duct tape?
        https://forums.unrealengine.com/deve...amic-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.

        Comment


          #5
          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.

          Comment


            #6
            Originally posted by Alex Mees View Post
            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

            Comment


              #7
              Originally posted by Alex Mees View Post
              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.
              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.

              Comment

              Working...
              X