Download

How can I detect when player camera does a full 360° yaw rotation in the air?

When my first person player jumps in the air, I want to award points based on how many full camera turns the player does before landing (by moving their mouse/joystick). I want this to work in either direction, so you can do the 360 clockwise or anticlockwise, and I want the amount of full rotations to be stored in a variable.

The furthest I’ve gotten is setting an initial yaw angle variable when the player first jumps, but I can’t wrap my head around the math to find if the yaw of the player in the air is a full 360 degrees from the initial angle. How would I do this?

If I could get some pointers, that’d be great. thanks all. :slight_smile:

Can you please show me how do you handle rotation input?
Also, remember that PC players with gaming mice can easily abuse this mechanic by simply creating a macro that will increase sensitivity. In case of very high sensitivity player can not only get too many points but also, if there will be more than one rotation per frame many turns can be not counted.

  1. Get the Yaw at the initial jump. You’ll need to calculate the offset it converts to 0.
  2. Get in what direction the player is rotationg (this will be locked until char lands)
  3. Get Yaw each frame and Apply same offset and store on another variable only if value is greater than previous (so player can “wiggle” and wont blow up the entire thing.
  4. When this second variable > 359.9, ++ the int where you store rotation count and reset yaw to 0.

Something along those lines.

I’m not too worried about players cheating, it’s a single player game and the points are just for fun, they don’t contribute to the gameplay too much – if the player wants to cheat, then so be it :slight_smile:

Let me visualize what I’m trying to do and what I’ve tried:

This is how I’m handling input, just a simple add controller yaw/pitch.
7ab2307d7e43dce0452dd6fb6b0f498d

When the player jumps, and does a full rotation in the air before landing (example in video), they get a point (or something else, it doesn’t really matter right now). Eventually I’ll do a check so the player can only do this if their velocity is high enough.
2022-01-02 12-50-53.mp4 - Google Drive

I set an initial yaw variable to the yaw of the pawn’s control rotation when the player jumps, and a bIsInAir bool, so I can reference it in an event tick to check the player’s yaw in the air every tick.

Now, on event tick I can check what the yaw of the player is when they’re in the air. By @pezzott1’s advice, I need to offset the current yaw from the initial yaw. I’ve done this (incorrectly) by subtracting the current frame yaw by the initial yaw. It kind of works, if I jump at yaw 270, I get a value of 0, so when I move the player view right (in air) to, say, yaw 300 – the delta yaw will be 30. However, when the current yaw reaches 360, it rolls over back to 0, so the delta yaw becomes -270, which I don’t want. I hope I explained this right, I know I’m offsetting the value incorrectly, but I think I’m going in the right direction.

Thanks for helping me out :slight_smile: