Hello everyone,
does anyone know how can I detect the direction of a mouse input? Basically, when the player clicks the right mouse button and drags the mouse (whilst holding the mouse button), how can I tell the direction he is inputting? E.g. up-down, down-up, left-right, northeast-southwest, etc.
Thank you very much for your time and for your help.
You can use IE_Pressed to store the mouse position and start a “hold status” and then use IE_Released to know the end of the “hold status”… Then compare the stored position with the current mouse position and you will get the drag direction.
@Tabriz
Thank you very much for your answer. But how do i compare the 2 stored values to get the direction?
Would something like this math operation work?
let’s say i have to 2DVector variables: v1 and v2
v1: stores the value when the mouse button is pressed
v2: stored the value when sometime has passed and the mouse button is released
and then to get the direction i make this:
note* i didn’t write it the way it should be in ue4 i suposse. Please bear with me as i’m learning it yet.
ok thank you once again Tabriz.
So if this formula works for the direction in a 2d space.
Would this one work to get the direction in a 3d space?
This time the vectors variables should be 3D instead of 2D
Vector1: stores the value when the mouse button is pressed
Vector2: stores the value sometime after and when the mouse button is released
Will zdirection get the correct direction from Vector1 to Vector2 in the scene?