Original Post
I'm having a lot of trouble deciding how to implement a pretty simple gimmick. I read mouse movement offsets (x,y) per frame, and they can vary when the frame rate is lower or higher. Such as something like -5,2 with a low frame rate, and -1,0 with a high frame rate. What I want to do is find a 2D direction vector, which allows the player to choose what type of attack to launch when an attack button is pressed. So, for example, if the mouse has been moved "mostly" up before the attack button, an upward attack is launched. If it has been moved "mostly" diagonally left-up instead, a different attack is launched. Once I have a direction vector for the mouse, "mostly" becomes an easy dot product operation. My trouble is finding the vector. What would be the best way to do that? 1. Do I record the mouse movement values into offset nodes, one for each frame, and throw away the oldest ones when the total distance reaches a certain value? When the attack is launched, the nodes would all be added together and normalized. 2. Should I record offset nodes per frame, then throw away the oldest ones based on time? Same as above, summed up and normalized on attack. 3. Should I just add each mouse offset, per frame, into a single vector, and average it based on time? 4. Should I add each mouse offset, per frame, into a single vector, and renormalize it each frame? 5. Something else? What I really want to find is the most recent movement vector. But all of these would give me that in different ways. Which do you think would work best for my intended application? I really appreciate any advice.