I have a gun which you can aim down the red dot sight. If you are moving while aimed down sight, there is some bobbing that comes into play. The arms are bobbing, not the camera itself.

Currently when the player fires their gun, I fire a ray from the center of the camera and check for a hit on a player.

The problem is, if the player is aiming and moving, the red dot is bobbing(since the arms are) but because the camera isn't, the ray always fires down the center which doesn't line up with the red dot. It Doesn't feel right in gameplay.

I was hoping someone may have some ideas to offer on how to handle this..


The pragmatic solution would be to not fire from the camera but to fire from the weapon model instead... at least when the player is in aim mode. When the player is not aiming with the weapon, the line of fire might be set off, which might seem a bit strange. Also, your gameplay is now affected a lot by your animation design, which gets cumbersome to balance.

What many games are doing instead is always having a random bullet spread, but make the intensity of the spread different depending on the current state of the player-character.

When you calculate a bullet trajectory, change the pitch and yaw by a random value. Use a small random value when the player is standing and aiming and a much larger random value when the player is running and firing from the hip. The bullets still won't land exactly where the gun is pointing at that moment. Instead the bullets will be spread all over the place, which is likely what the player expects to happen.

  • \$\begingroup\$ One possibly annoying effect of this solution however: It decreases the chance of being a Very Good shooter/aimer, which is one of the big challenges (and desires) in fps games (i for example was a "good" shooter in a game long ago, and got a lot of "respect" for that :-)). Random is same for everyone, and if it has a majority role, skills get more of a minority role. But ofc, the game & animation design have a big importance here. From a coders point of view, this solution is practical. And if being pragmatic (i am to some extent), i'd go with exact models for as long as possible. \$\endgroup\$ – Stormwind Mar 31 '17 at 16:04
  • \$\begingroup\$ Thanks for your help. My concern with firing from the weapon model is that I feel it will not consistently line up with the red dot even if I just do it while aiming. A reason that comes to mind is I also have a weapon sway effect when you look side to side or up and down. It was also suggested to me to bob the camera instead of the arms and gun but I would think you wouldn't get the same motion feel since the entire camera bobs instead of just the arms & gun. \$\endgroup\$ – Adam Nunez Mar 31 '17 at 16:07
  • \$\begingroup\$ How about making it steadier over time? If there is a rush in the game? No time to be still for long = bad aiming. Risking to invest in eg. 5 secs = good aiming BUT bigger chance to get slaughtered? Then the user has options. \$\endgroup\$ – Stormwind Mar 31 '17 at 16:18
  • \$\begingroup\$ @Stormwind not really that much of a problem if you provide feedback for the current random roll (e.g. you show current displacement as offset of the red dot) \$\endgroup\$ – wondra Mar 31 '17 at 17:57
  • \$\begingroup\$ But the red dot was not exact in the 1st place! :-) \$\endgroup\$ – Stormwind Mar 31 '17 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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