If I want to click on the LMB and while I am holding it, move the mouse in any direction, I need to be able to tell which direction and how many units the Mouse was dragged before release. How to do it?
Thanks …
If I want to click on the LMB and while I am holding it, move the mouse in any direction, I need to be able to tell which direction and how many units the Mouse was dragged before release. How to do it?
Thanks …
Do you want to get the direction and distance from the mouse since you pressed it? I get you?
To check it while the mouse button is pressed:
Distance = sqrt( (a-x)^2 + (b-y)^2 )
Angle = atan2( (b-y) , (a-x) )
Incredible and complex at same time kkk’
Motivated me to study mathematics to build complex codes… hard task
Ok, I think I got simpler solution, but it will only work in 8 directions (you would only be able to tell if mouse moved up, down, left, right or in diagonals).
If you’re okay with this, here it is.
First you’ll need 4 variables.
Kinda wall of text, but concept is really simple once you read it and try.
If you want just the absolute values (how far is it from the point you started to the point you finished at), there is yet another alternate method.
[u]Conditions: [/u]
LMB is pressed
Variable x = 0
[u]Actions: [/u]
Create an object lastmousepos at Mouse(X,""), Mouse(Y,"")
Do = 1 to Variable x
[u]Conditions: [/u]
LMB is NOT pressed
Variable x = 1
[u]Actions: [/u]
Create an object endmousepos at Mouse(X,""), Mouse(Y,"")
Do = 1 to Variable x
And then you can compare the distance and angle between objects lastmousepos and endmousepos.
If you want to know very accurately how may units were traveled in total, then you could create a waypoint every x seconds (or even frame) and then calculate the distance from the last waypoint while the mouse is pressed. This is important if you want to know how far I traveled and I took a route like the one in the attached picture.
Thank you everyone, the solution is definitely complex, I will try them out and see which goes the best …