How do video game bullets and projectiles work?
-
MrDow123
- Posts: 65
- Joined: 2007-08-08 17:10
How do video game bullets and projectiles work?
I've wondered this question for years and years and could never figure out an answer.
How do video game projectiles work? How do you get trajectory and tracers to actually work in PR? When you click the left mouse button to fire your weapon, how do the bullets reach the target?
Could someone please explain this to me? I know how bullets work in real life because I use bullets to hunt big game at long range, so I have to know trajectory and velocity, but I dont understand how it works in the game world
How do video game projectiles work? How do you get trajectory and tracers to actually work in PR? When you click the left mouse button to fire your weapon, how do the bullets reach the target?
Could someone please explain this to me? I know how bullets work in real life because I use bullets to hunt big game at long range, so I have to know trajectory and velocity, but I dont understand how it works in the game world
Steve: "I've got an M4 attached with an ACOQ Reflex sight, an M203 Grenade Launcher, a 4X power scope, a bipod, a massive night vision scope, a flashlight, a lazer pointer, a suppressor, a drum magazine, and a cappuccino maker"
Dan: "Mhmm, interesting. And how much does the gun weigh? Whats the recoil like? How accurate is it?
Steve: "About 50 pounds, it broke my shoulder when I fired it, and it couldn't hit the broad side of a barn. But it sure looks cool"
Dan: "Mhmm, interesting. And how much does the gun weigh? Whats the recoil like? How accurate is it?
Steve: "About 50 pounds, it broke my shoulder when I fired it, and it couldn't hit the broad side of a barn. But it sure looks cool"
-
blud
- Posts: 1246
- Joined: 2006-09-04 22:22
In most games the bullet doesn't travel, and there actually is no bullet. When you fire on someone it just immediately registers a hit on them, on anything that is in the path of where your gun is pointing.
But in PR/BF I *guess* the bullets are proper projectiles? In which case I can only assume that basically the bullet becomes an entity in the game, just like a tank or a soldier, and the bullet flys across the map to its destination.. but.. someone else might know this for sure.
But in PR/BF I *guess* the bullets are proper projectiles? In which case I can only assume that basically the bullet becomes an entity in the game, just like a tank or a soldier, and the bullet flys across the map to its destination.. but.. someone else might know this for sure.
-
Paladin-X
- Retired PR Developer
- Posts: 592
- Joined: 2005-06-12 16:00
When a weapon is fired a projectile object is created. The path and speed are calculations done by the game. We can modify those variables that will affect those calculations in the code. For example we can define the speed by this line: ObjectTemplate.velocity 925. (925 meaning meters per second I believe). We can modify trajectory with the 'cone of fire' and change gravity variables as well.
Gravity:
ObjectTemplate.gravityModifier 0.3
'Cone of fire' (Path deviation)
ObjectTemplate.deviation.minDev 0.15
ObjectTemplate.deviation.setFireDev 0.7 0.2 0.05
ObjectTemplate.deviation.setTurnDev 1.5 0.2 0.2 0.1
ObjectTemplate.deviation.setSpeedDev 2.55 0.2 0.1 0.12
ObjectTemplate.deviation.setMiscDev 4.8 2.5 0.1
ObjectTemplate.deviation.devModStand 1.1
ObjectTemplate.deviation.devModCrouch 0.6
ObjectTemplate.deviation.devModLie 0.3
ObjectTemplate.deviation.devModZoom 0.4
I don't remember exactly what each number represents, so unfortunately I can't explain that one further.
Also, with BF2 the path of the bullet is calculated like 30 times per second or something like that (I don't remember the exact number). The bullet will end if there is a collision or will expire (disappear) as per the timetolive setting. With BF2, some bullets have a penetration property as well, so that it may not necessarily stop on collision. As well as a ricochet property that can send the bullets bouncing around.
As for tracers... we can make these otherwise invisible bullets show up by setting the tracer properties. We can define the size, when it will fire (ex every 5th bullet) and colour. Here are some properties of tracers:
ObjectTemplate.tracerScaler 20
ObjectTemplate.maxTracerScaler 30
ObjectTemplate.minTracerScaler 10
ObjectTemplate.tracerSizeModifier 5
ObjectTemplate.tracerConvergeDistance 20
ObjectTemplate.tracerTemplate p_tracer_r
ObjectTemplate.tracerInterval 5
NOTE: Some weapons have actual modelled projectiles, such as the M203.
Gravity:
ObjectTemplate.gravityModifier 0.3
'Cone of fire' (Path deviation)
ObjectTemplate.deviation.minDev 0.15
ObjectTemplate.deviation.setFireDev 0.7 0.2 0.05
ObjectTemplate.deviation.setTurnDev 1.5 0.2 0.2 0.1
ObjectTemplate.deviation.setSpeedDev 2.55 0.2 0.1 0.12
ObjectTemplate.deviation.setMiscDev 4.8 2.5 0.1
ObjectTemplate.deviation.devModStand 1.1
ObjectTemplate.deviation.devModCrouch 0.6
ObjectTemplate.deviation.devModLie 0.3
ObjectTemplate.deviation.devModZoom 0.4
I don't remember exactly what each number represents, so unfortunately I can't explain that one further.
Also, with BF2 the path of the bullet is calculated like 30 times per second or something like that (I don't remember the exact number). The bullet will end if there is a collision or will expire (disappear) as per the timetolive setting. With BF2, some bullets have a penetration property as well, so that it may not necessarily stop on collision. As well as a ricochet property that can send the bullets bouncing around.
As for tracers... we can make these otherwise invisible bullets show up by setting the tracer properties. We can define the size, when it will fire (ex every 5th bullet) and colour. Here are some properties of tracers:
ObjectTemplate.tracerScaler 20
ObjectTemplate.maxTracerScaler 30
ObjectTemplate.minTracerScaler 10
ObjectTemplate.tracerSizeModifier 5
ObjectTemplate.tracerConvergeDistance 20
ObjectTemplate.tracerTemplate p_tracer_r
ObjectTemplate.tracerInterval 5
NOTE: Some weapons have actual modelled projectiles, such as the M203.

-
PlatinumA1
- Posts: 381
- Joined: 2007-06-25 07:31
-
Dunehunter
- Retired PR Developer
- Posts: 12110
- Joined: 2006-12-17 14:42
-
Expendable Grunt
- Posts: 4730
- Joined: 2007-03-09 01:54
I actually posted over at game dev about making a "physics gun" that actually has a magazine full of bullet models that actually fly out of the gun based on a physics model similar to blowing up a grenade next to something in HL2 -- uses the explosion and containment to fing it the right way.

Former [DM] captain.
The fact that people are poor or discriminated against doesn't necessarily endow them with any special qualities of justice, nobility, charity or compassion. - Saul Alinsky
-
El_Vikingo
- Posts: 4877
- Joined: 2006-11-27 01:50
From what I understood from Eggmans post about how bullets travelled in BF2:
The bullets go straight and then drop off at the designated range the rifle was zeroed into. In real life the bullet would travel upto reach further distances.

The bullets go straight and then drop off at the designated range the rifle was zeroed into. In real life the bullet would travel upto reach further distances.


If you are reading this dont stop, cause if you do, I'll kick you in the balls.
-
El_Vikingo
- Posts: 4877
- Joined: 2006-11-27 01:50
-
KingofCamelot
- Retired PR Developer
- Posts: 2365
- Joined: 2006-01-07 18:17
Paladin-X explained it pretty well, but I'll also note that DICE used basic high school physics equations throughout the game.
While playing around with the mortar the other day in the editor I could do some simple math and calculate at what distance the round was going to land. Was kinda cool.
Only oddity you have to account for is that DICE used 14.8 m/s*s as gravity in-game, instead of the 9.8 m/s*s in real life. Not sure why they did that tbh.
While playing around with the mortar the other day in the editor I could do some simple math and calculate at what distance the round was going to land. Was kinda cool.
Only oddity you have to account for is that DICE used 14.8 m/s*s as gravity in-game, instead of the 9.8 m/s*s in real life. Not sure why they did that tbh.
Ruthless Executioner of 280 SpamBots
Retired Lead Coder for Project Reality - 0.25 through 0.4
Retired Lead Coder for Project Reality - 0.25 through 0.4
-
Expendable Grunt
- Posts: 4730
- Joined: 2007-03-09 01:54
-
requiem
- Retired PR Developer
- Posts: 3651
- Joined: 2004-07-22 16:00
-
MrDow123
- Posts: 65
- Joined: 2007-08-08 17:10
Thanks for the answeres DEV's and Members 
Steve: "I've got an M4 attached with an ACOQ Reflex sight, an M203 Grenade Launcher, a 4X power scope, a bipod, a massive night vision scope, a flashlight, a lazer pointer, a suppressor, a drum magazine, and a cappuccino maker"
Dan: "Mhmm, interesting. And how much does the gun weigh? Whats the recoil like? How accurate is it?
Steve: "About 50 pounds, it broke my shoulder when I fired it, and it couldn't hit the broad side of a barn. But it sure looks cool"
Dan: "Mhmm, interesting. And how much does the gun weigh? Whats the recoil like? How accurate is it?
Steve: "About 50 pounds, it broke my shoulder when I fired it, and it couldn't hit the broad side of a barn. But it sure looks cool"
-
El_Vikingo
- Posts: 4877
- Joined: 2006-11-27 01:50
-
KingofCamelot
- Retired PR Developer
- Posts: 2365
- Joined: 2006-01-07 18:17
Its not twice, its about 1.5x.El_Vikingo wrote:Why twice the amount of it in RL? Can you guys change this amount? If so, would it change the gravity to low gravity, so to say?
Like I said, no idea why they have it set to that, but thats how the game is configured. Changing it now would make it seem like low gravity, and cause everything to go to shit.
Not really a big deal, you never even knew.
Ruthless Executioner of 280 SpamBots
Retired Lead Coder for Project Reality - 0.25 through 0.4
Retired Lead Coder for Project Reality - 0.25 through 0.4


