I have been searching online and weirdly I can’t find anyone talking about this? It seems like it should be simple but I really can’t figure out how to detect if the player is rotating Clockwise or Counter-clockwise.
For reference, my game has tank controls (its a retro-like survival horro game) and I want different animations to play if you’re rotating left or right
Hello Mastatatoe,
Interesting problem, I first wondered if dot product could be used (comparing previous vector to new vector) - But that only returns a positive number until you are past a 90 degree threshold with the previous vector. (So for example if you look 45 degrees to the right or left that will return the same positive number)
I then thought - 'Why not just compare the current yaw with previous yaw to see which direction the rotation happened in?" this works ok, up until a hiccup on the threshold between +180 and -180.
Then I found the ‘Delta (Rotator)’ node - and the hiccup was solved:
This is a very ‘raw’ way to get rotation direction, In the context of animation some other paths might be basing it on player input actions, also there’s probably something built into the animation system to help with this. (something something blend spaces?)
Hello there ![]()
There are 2 ways I can think of:
- Very simple - get the input. Pushing the “Turn Left” button? Oh well…
- Record the last tick forward direction (prev). Cross product with the current forward vector (cur) gives you a vector that is perpendicular to both. Now you only have to see if it is pointing up or down. You can only compute the Z of the cross product and check if it is positive or negative.
flaot crossZ = cur.x * prev.y - cur.y * prev.x
(the Z optimization is only possible if you are sure you are turning horizontally)
If it is the player you can just check the axis of your input (which is a float) and check the sign. (Sign Node or check if negative)
If it is for anything else, it requires a Previous Forward value that you can check with.
what I would do instead if you are using the second method, I would store a PreviousForward Vector of the actor or character. (you can make it planar by making a Vector of X and Y only and ignore Z for Yaw only). Then use Find Look At Rotation.
The setup should look like this (Make sure to store the PreviousForward in BeginPlay)
I also recommend you not using the last method if it is solely the player input related since it is gonna be ticking every frame on the game thread. For player it only is one object that is calling this. But for NPCs and etc, I would not advise you doing it. I would just use the input checks for player, and for AI I would just check if the direction of Me to player with Direction of my current forward once and would store it to rotate. (same setup as above almost)
But if it is something like the player camera or anything that needs this really or something that is only there 1 time in your level, the solution works perfect (and add the condition for checking 0 if you want it as well)
thank you so much this worked perfectly mixed with some booleans and calling it in an animation blueprint + state machines.
this issue was really crushing my balls, really smashing them slowly with a hammer, truly putting them in a hydraulic press!
Glad to hear you got it working! There’s probably some more appropriate idioms to use - like “I was really banging my head against the keyboard here”
![]()
I’ll concede that I like the solution that @dZh0 provided better. I was on the right track with using vector math, and should have realized that cross product would have done the trick instead of dot product. It’s also more elegant in the fact that it uses only 1 variable instead of 2 and has built-in checking to prevent it running more often then it needs to (!= node)



