How much mouse moved after one second

Hey guys,

I was trying to find out how much the mouse moved (and in which direction, basically to get a 2D vector) after one second. So basically, when the player presses the mouse we store the current value, add a timer or delay for 1 second, then get the value again, correct? Problem is, which function can I use to get the real position of the mouse?

Does anyone have tips?

  1. Make a CustomPlayerController blueprint that inherits from PlayerController.
  2. Add a float variable to CustomPlayerController named PreviousMouseX.
  3. Add a float variable to CustomPlayerController named PreviousMouseY.
  4. Create a SetTimer and add it to EventBeginPlay, set FunctionName to TickEverySecond (just type it in) and set it to 1 second and looping to TRUE.
  5. Create a custom event called TickEverySecond.
  6. Set PreviousMouseX to the value of GetMouseX in TickEverySecond.
  7. Set PreviousMouseY to the value of GetMouseY in TickEverySecond.

Now you can access previous seconds X & Y coordinates with those variables. How to get how much it has moved is just simple math: PreviousMouseX - GetMouseX.

Try this, also

Thanks for the help and !