I’m working on some fanciness today. Previously our character would ‘snap’ to an animation and movement speed with a button was pressed – i.e. if you were walking and you hit the sprint button, the character would instantly go from 200 speed to 600 and the animation would instantly change from walk to sprint. My goal today was to implement smooth transitions between movement modes - change speed over time.
I’ve successfully accomplished this with sprinting and walking, but crouch walking is giving me a bit of an issue.
The crouch animation is jittering like crazy, and I strongly believe it’s because the Max Walk Speed is never hitting exactly 80.0. I think because its being adjusted by (Delta Seconds * 600) it’s probably giving a float in return that might or might not actually be near 80. It could be bouncing between 78.3 - 82.7 (or 79.9 - 80.1) constantly. My question isn’t really about “what’s wrong”, but more about “how would you go about clamping this formula so that as it approached 80 it would rest exactly on 80.0?”