How do I consistently know which direction the character will pivot when orienting to movement

So I tried this, and it still only works when not doing a 180, in which case the character may be turning the opposite direction than what the “pivot direction” variable says