Head bobbing camera movement (Javascript, home made)

I got the camera bobbing from a non home-made script, and by non ome-made i mean one from the community and not made by others like you reading this thread, i’m looking for a more advanced thing that makes the camera move (Ever played crysis?) in a more realistic fashion and stops bobbing while walking into a wall. the script is about 80 lines long so i wil give you a link to pastebin: Headbob script :D - Pastebin.com

i already made the script non-frame independent so the bobbing is always the same no matter the frames you got and also stop making it bob is you were to be walking and pause the game the head would keep moving up and down. it’s been all day for me trying to figure this out with barely any success. thanks to whoever answers this even if it’s spam xD (That’s how desperate i am).

The head bobs because your using key input to make it bob and to walk forward, walking into a wall is still using the controls and thus bobbing, maybe making it bob on a certain vector velocity will give you the effect you want.