View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# How would you simulate gun recoil in a FPS ?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1jokoon  Members

Posted 15 March 2012 - 05:59 AM

My goal is to remake the counter strike recoil feel, especially for automatic guns, and I'm having an hard time.

I was told on math.stackexchange with this function https://www.google.fr/search?aq=f&ix=hcb&ie=UTF-8&q=plot+5x*e%5E(1-5x)+from+0+to+1
which sort of simulate some sort of impulse, to tweak its quickness I just have to change '5' to something else, and it still results with something between 0 and 1.

For single shots it behave quite nicely, but with automatic guns in counter strike, the recoil sort of accumulate and adds up to an higher angle.

Any idea with some kind of equation or algorithm ?

### #2softdev  Members

Posted 18 March 2012 - 11:08 PM

By the looks of the plot in the link you provided, the curve looks right to what you said. I changed the 5 in the exponent to 9 and got the spike I think you are referring to. To cut a long story short, unless you have a downward force applied through whatever physics engine you use, it won't work. However it works perfectly fine if you simply limit the y with whatever you get for the result. So each gun can have a different limit. This would be up to you and how you are processing the recoil. Don't change the curve, the algorithm is fine. Just don't forget, that if you later want to use more accurate physics for the character (ie. 3rd person view), you are getting a visual translation as opposed to a gravity calculation.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.