Nerd moment! It’s very simple actually!
- Randomly generate a value of (-1 or 1) lets call it “x”.
- Create a “factor”, “max_angle” (mine is 45deg) and “difference”(i used 0.2) variables. (NOTE: difference should be anywhere from 0 to 1, higher = faster angle variation.)
- Set “factor” to (“factor” + “difference” * “x”) and clamp it between -1 and 1.
- Take your player input direction vector and rotate it around (“max_angle” * “factor”)
You can use lerp, to smooth out the movement. Thanks for asking. I love nerding about my stuff!