Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How would you do it?

I already found this function for an impulse (helped by math.SE). It works for single shots, but not for automatic weapons.

Any ideas?

share|improve this question
    
a similar question was posted [here][1]. [1]: gamedev.stackexchange.com/questions/7276/… –  PATRY Mar 16 '12 at 17:23
    
I know, bit it doesn't give much clues. –  jokoon Mar 16 '12 at 17:29
add comment

2 Answers

up vote 5 down vote accepted

Just combine the individual shots' impulses? Something like this:

multiple shots, overlapping

You could of course add realism:

Particularly when firing on automatic, humans have a tendency to get used to the recoil. Basically, there is some factor that decreases the recoil impulse down to some point. The first shot recoils hard and the following shots add to the kick, but each with decreasing force, until some saturation in the soldier's capability for holding the gun steady is reached. This could be done with a function that modulates that impulse function based on the time since the last shot and the number of shots taken in the same chain of automatic fire.

A slight random factor is also always present in reality.

share|improve this answer
    
"Just sum up the individual shots' impulses?" : nope, I already tested it, and it's awful, for the following simple reason: the time the camera angle takes to return to the original position, is the same if you shoot 1 or 10 bullets. I have to "stretch" time to make the fall back take more time. Quite simple actually: create some factor and multiply the time I add to my time buffer by this factor, this way I "stretch time". But it's tricky, because I have several time buffers, so which one do I apply the factor on ? I guess all of them. –  jokoon Mar 15 '12 at 18:05
1  
@joko I added a doodle to better show what I meant. I don't know see what you mean with the "time stretch"... Surely it would be realistic for the gun to return to the same position just as quickly regardless of how many bullets were fired? –  Anko Mar 15 '12 at 22:18
    
this is not the counter strike feel, because it caps to same maximum angle if you shoot 1 or many bullets. But I could apply a multiplier –  jokoon Mar 16 '12 at 8:09
add comment

well basically, just have some kind of (semi-randomized) rotation that will cause the gun to jerk in an upward direction, and just apply it for every shot

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.