Better way to make a Weapon Bob animation when walk

Hi, what could be the best way to make a weapon bob animation when the player its walking or running on a FPS?

Using a predefined animation for each case, and then play the animation when the player its walking or running with a script…


make the weapon bob animation using only script (i dont know how to do it yet, perhaps its easy to manage the animation transitions this way?).

Thanks for any advice on how to do it the better way…

The easiest way, for me at least, would be to animate it, scripting your way out of something like this would require that you had some bones to which you could add some rotation scripts, to simulate movement, getting that stuff right wouldnt be an easy task.

On the other hand, if you use an animation you’d have full control over the character and the weapon bob animation, and it would be way easier to make adjustments.

the easiest way to make the weapon bob using script would be to change the y position over time using a sine or cosine function with the Mathf.sin() of Mathf.cos(). If you don’t understand what that means it would be easiest for you do pre written animation