0
\$\begingroup\$

In game's like Battlefield or Arma, how many times per second is the position of a bullet calculated?

\$\endgroup\$
  • \$\begingroup\$ Specifically, Battlefield servers used to run at a fixed 30hz tick-rate. Recently, the ability to increase the tick-rate up to 120hz was added, although most of the servers running enhanced tick rates run at only 60hz. \$\endgroup\$ – Jon Feb 7 '16 at 5:08
  • \$\begingroup\$ Also, keep in mind that an individual client may be "updating bullet locations" at 1000fps (smaller and more frequent updates) but the server is only notified of those changes TickRate times per second. If a bullet moves in a straight line and is on one side of you in frame X and on the opposite side of you in frame X+1, you know you'll need to check for collision. \$\endgroup\$ – Jon Feb 7 '16 at 5:20
  • \$\begingroup\$ Also, also, there is very little reason to calculate a new bullet position every frame; you only need to integrate the bullet's accumulated flight time. Given the starting point, firing direction, and elapsed flight time, the current location can be calculated. Instead of re-drawing the bullet model at every point along its' trajectory, the entire path is often summarized visually with a brief 'vapor trail' effect. It takes many frames for the actual position of a bullet fired from across the map to matter to a player; it only matters for the last inch. \$\endgroup\$ – Jon Feb 7 '16 at 5:32
1
\$\begingroup\$

You should use projectiles only for comparatively slow "bullets" like grenades from a grenade launcher or RPGs.

For very fast bullets like bullets fired from a gun, A ray cast (or a ray-world intersection test) is used instead. A ray is fired from the barrel of the gun (origin of the ray) in the direction the character is aiming (direction of the ray). If the ray hits something, the hit is registered to the code handling bullet hits after a delay which is proportionate to the distance of the hit point from the ray origin.

If you take the average muzzle velocity to be say 1 km/s, the time delay can be calculated using the simple time = distance / speed formula. In most cases, the distance will not be more than 100 meters (unless using sniper rifles). If the delay is more than say 0.1 seconds, you could check in the code handling bullet hits whether the object hit (or its bounding box) still contains the hit point. If it does, the bullet has hit that object.

You could do extensive research and find the muzzle velocity of each gun you have in the game and use it for each gun separately, or you could use an average figure.

| improve this answer | |
\$\endgroup\$

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.