• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved] Dragging object relative to mouse position?

E

Edwin

Guest
I want to make a simple object dragging system, but when I drag the object it teleporting to mouse position relatively it's position offset.

How it looks like:
Reality.gif

How I want it to look:
New Piskel.gif

Well, I tried to animate it realistic and I hope you get my point.

So, how I can add mouse position to the object position offset?
 

FrostyCat

Redemption Seeker
When the mouse button is first pressed, measure the coordinate difference between the mouse position and the origin of the target being clicked. Then while the mouse button remains down, snap to the mouse position plus that difference.

See this example solution, where mdx and mdy represent the said coordinate difference.
 
E

Edwin

Guest
When the mouse button is first pressed, measure the coordinate difference between the mouse position and the origin of the target being clicked. Then while the mouse button remains down, snap to the mouse position plus that difference.

See this example solution, where mdx and mdy represent the said coordinate difference.
Oh, thanks! It turned out that it was very easy to do!
 
Top