Dragging factory created game objects

I have an object that was factory created. The plan is to have the mouse be held down, then the object will move with the mouse until it is let go. All of the mouse movement things I have seen have been relating to following or going to the last clicked position, so I was wondering if this was even possible, and how to do it.

Thanks for the help

You can use a game object with a collision object which follows the mouse cursor and then have a collision object on the created object. When the two collide you can also check mouse button state to move it around.

Here’s a ready to use solution for this:

HTML5 demo (select Cursor example): Defold-Input 0.1

Hello there,

have you seen the great videos by Tactx Studios:Defold videos. Number 3 deals, amongst other things, with dragging and dropping and gives a good explanation of the solution @britzl has posted.

Thank you for the help, I’ve got it to work
:slightly_smiling_face:

1 Like