So I have a first person shooter game, and I thought it would be a cool feature to be able to detect when a player hits a trickshot, such as a flick or 360. I thought about maybe getting the previous camera orientation and using to see how much it’s moved (because in a flick or 360 the camera would have moved quite a bit prior to shooting), and if the camera moved fast enough it would count as a trickshot.
Any feedback on how I could do this better would be appreciated!
There’s probably a better way to do this, but I would start by recording the camera’s position every 0.05 seconds, and storing those positions in a table (Limit the table’s length to 20 * maximum time for trickshot). Once a hit is detected, you iterate through the table to see if a circle was formed by the previous camera positions.
You could track the rotation of the player when they’re in the air. If they’ve rotated 360 degrees and then shoot, that’s a 360. You can also track the time that the player scoped, if it’s below … 0.3s, then it’s a quickscope.