Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / How do iron sights in games work?

Author
Message
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 01:06 Edited at: 10th Aug 2009 07:57
I was putting the finishing touches on a gun I was making in blender (that I traced from a reference image of an m1911), and as I was editing the iron sights, I started to think about current day games. How do they aim the gun's iron sights at an enemy at any distance, and the bullet still goes to the iron sight? I mean, if you're in a room and you stick your gun to a wall while aiming through the iron sights, the bullet (or at least the bullet hole) appears on the the wall exactly where your iron sight is aiming. The same goes for shooting an enemy at a distance (and I mean like in [if I remember] COD5, where you have to snipe down this person with a pistol for an acheivement or trophy (depending on the game console you're playing with). How is it that you the bullet still goes to where the iron sight is aiming, I mean the iron sights are above the barrel of the gun, and even though if you allign them, they still form an angle with the field of aim with the barrel that eventually gets out of correct aim... Here, I just whipped up a quick illustraion for what I mean:
I also attatched a larger version of the image to this message, so if anyone wants to study the picture better, they can. EDIT: Oh yeah, here's a key:
-----------------------------------------------------
yellow line = field of aim for the barrel
red line = center of the yellow line
black line = Aim of the iron sights
yellow(-ish) circle with a black "X" in it = Where the iron sight aim intersects with the barrel's aim
-----------------------------------------------------
And I made the gun color red because it's more noticable in the background, but mainly because I was measuring the height of the iron sight in the back of the gun, for I didn't have a reference image for that, but off of studying the real gun the illustraion is techinically correcy.

Attachments

Login to view attachments
lazerus
16
Years of Service
User Offline
Joined: 30th Apr 2008
Location:
Posted: 10th Aug 2009 01:26
Youv answered your question with your diagram, the bullet will line up to a sweet spot,

It comes down to two factors, power and calibration,

Ive calibrated my rifle for a 50m 'sweetspot' using a firing rig and some calculations done by a friend.

Power comes into play as the bullet can hold its trajectory longer, my rifle as said is pinpoint to 50m in a dry breezeless

you also have a few other factors to consider, moisture, wind, DP-depth perseption among other things.

Games eliminate most of these and put a algorithims to cal the trajectory.

"the wind bothers me, its sudden acrid coldness. The world around me darkens and the moon seems distant, unforthcoming, hostile"
http://lazerus-reborn.deviantart.com/
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 02:00 Edited at: 10th Aug 2009 02:13
Quote: "Youv answered your question with your diagram"
Not really. This is how I tested in a game, compared to real life in an anaology: Say in real life you put the barrel of your gun up to a wall. You shoot, and the bullet hole appears where you were aiming the barrel. Now in a game, if you put your gun's barrel up to a wall while aiming through the iron sights, the bullet hole will appear where the iron sights are aiming. How does that work? Do they program it so that (in imagination) a line appears where the iron sights are aiming, and a line appears where the barrel is aiming. When you shoot, the line for the barrel is visible for a split second, but the other iron sight line isn't, and the bullet hole appears at the end of the invisible iron sight line. Yet I still don't get it... after some thinking I think it might have something to do with the recoil: (Not exactly the same way, but in example), take the two line theory again, except both lines are invisible. When you aim the gun, the iron sight invisible line is aiming at an object, and then it's coded and animated so that when you shoot the gun, the recoil of the gun in the game (which I noticed goes unreasonably up) moves the gun high enough so that the invisible line of the barrel is aiming at the exact same place as the invisible line for the iron sight. This is just a theory, and I know that they don't really have the "lines", but they're just used to illustrate an example. In my guess, using this method along with the timing of the smoke, the little gunshot explosion of the shot, and the sound effects, give you that effect. My guess is it might be done this way, but I'm sure I'm wrong so I'm asking for help. A friend told me once that with sniper rifles in games, the little line you see for the bullet when you shoot the gun is invisible to the shooter, but visible for other players, so technically when you aim down a sniper's scope, you're really aiming down the barrel, and since the bullet/bullet line is invisible to the player, nothing blocks you're aim when you shoot (and the smoke/bullet explosion thing lasts for a split second, aiming out of the scope won't be fast enough to notice the smoke. I'm doubt i'm right, so I hope someone can tell me...
Quote: "Games eliminate most of these and put a algorithims to cal the trajectory."
Hmm, also maybe when they aim the gun the gun is tilted in the players hand, so the iron sights are aiming straight, instrad of tilting down, and mathematically this way they avoid any aiming problems for the player, but when you shoot the gun, the actualy thing the players sees is still confusing, as in the angle of the barrel and the ironsight still confuse me, even if the gun is tilted or they use algorithims, for the player should still be able to see it... Anyways, thanks lazerus, that was a fast reply , and a helpful one too, yet when you say it like that:
Quote: "Games eliminate most of these and put a algorithims to cal the trajectory."
It kind of sounds daunting. But still, I've seen it work in some simple stuff, like FPSC for example. I've checked out some weapons in TGC Store (such as Errant AI's, and I notice that he is able to do this exact thing with something as simple as FPS Creator, so at least I know that it should be simple to program in something like DBP).
lazerus
16
Years of Service
User Offline
Joined: 30th Apr 2008
Location:
Posted: 10th Aug 2009 02:16
I dont sleep

"the wind bothers me, its sudden acrid coldness. The world around me darkens and the moon seems distant, unforthcoming, hostile"
http://lazerus-reborn.deviantart.com/
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 02:26 Edited at: 10th Aug 2009 02:28
Quote: "Games eliminate most of these and put a algorithims to cal the trajectory."
So what your saying, in much less daunting terms, is that the game creators (no pun intended) code the process of using the gun in various algorithims, along with other mathematical properties such as the rotation and position of the gun and the iron sights to make a firing process... Yup, I was right, seems daunting, but honesltly I think just thinking outside the box a little will give a simple answer to that... still need help though ...
Quote: "I dont sleep "
Haha
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 10th Aug 2009 02:36
I think Ironsights are pulled into the same place as the targeting reticule, (the centre screen), which is also the origin of the targeting raycast. Therefore, they land in the same place at close range in games...

The only thing is that modern games give ironsights a magical zoom and accuracy increase. If you go into ironsights, fire a shot, and find the focus of the sight, and place blutak there, then fire with the blutak aimed at the bullethole, it will normally miss...

If I was ever given the opportunity to remove all the bad from the world, I wouldn't, because for there to be heroism, compassion and all that is good, there must also be all that is bad.
Azunaki
15
Years of Service
User Offline
Joined: 11th Feb 2009
Location:
Posted: 10th Aug 2009 03:40
lol halo 3 fails massively on this. if you use the sniper shoot and go to the theater and follow the line it makes, it won't hit were the bullet hits. which makes you wonder if other games actually aim at the same place or if it just makes a cloud out the barrel and the actual bullet tracer goes from the sight out to were your aiming, and puts a small randomize on the accuracy for were it hits.

lol or else i just found a weird glitch on the bridge map that re angled it...

[url]http://myportfolio.x10hosting.com/[url]
visit my site.(still in progress)
Pbcrazy
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: ...pillow room...
Posted: 10th Aug 2009 04:06
Actually, that's more than likely what a good deal of small indie games do. It would be simple and pretty effective for just a quick game.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Aug 2009 04:18 Edited at: 10th Aug 2009 04:20
Games would most likely have the sight from the actual barrel of the gun, and not the sight at all. Or the bullet is calculated from the sight, and never uses the barrel at all.

SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 06:58
Quote: "Or the bullet is calculated from the sight, and never uses the barrel at all."
That much I get, but what about the way they make it look like the player shoots the gun and the bullet is shot from the barrel?
Sid Sinister
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 10th Aug 2009 08:56 Edited at: 10th Aug 2009 09:01
In games like Counter Strike, for example, the bullet never leaves the chamber. You aim, you fire, a bullet casing instance is ejected, a ray is draw and stops at the first thing in it's path, mathematical algorithms take place (from simple to complex physics), a decal sprite is placed (or if the terrain is destructible, continue complex physics algorithms) OR if it reaches an enemy, damage is dealt and possibly blood sprayed.

I don't play very many new 360 games since I don't have one, but the last time I played a realistic FPS, they just replaced the site with a sprite render while aiming.

PS: Yes, there is a sweet spot to real guns, and it does depend on the calibration. But in all honesty, most games lessen the extent of this reality in favor of laser accurate shots just because it's easier to play, more fun is had, and not everyone knows how real guns shoot - especially when there's a lot of different guns that each have their own personality. The developers of the new Americas Army game had access to all the military's data on all the guns the game used. AA is probably the one exception I can think of where real life bullet physics matter.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
Current Project: http://strewnfield.wordpress.com/ (Last updated 06/11/09)
lazerus
16
Years of Service
User Offline
Joined: 30th Apr 2008
Location:
Posted: 10th Aug 2009 12:10
Uh AA's where terrible untill they put the sites on, after that it was site shoot and burn, Used to know a AA gunner from WW2.

Glad i could have been of help.

"the wind bothers me, its sudden acrid coldness. The world around me darkens and the moon seems distant, unforthcoming, hostile"
http://lazerus-reborn.deviantart.com/
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Aug 2009 14:08
Thing is, if guns were too realistic then FPS games would be less fun, and some people would complain if a close range shot lands half an inch below the crosshair.

A crosshair will always be on the trajectory of the bullet, and it's best to use the bullet trajectory when zooming a sniper rifle - the problem would be amplified if you consider how complex a scope is to calibrate, really we want crosshairs to be that accurate if not realistic. When it comes to ironsights though, I guess most developers just cheat - like lower the gun by half an inch from the bullet trajectory.

I've tried being realistic with FPS guns and it just doesn't feel right without some complex work...

If you put the crosshair where the bullet will land it becomes a nightmare to peek around corners as the crosshair jumps as you leave the corner.

If you put the crosshair in the same place you basically have to get a sweep spot so the gun fires at that crosshair at a certain distance. Bullets don't fly like that. I mean if you have a fixed crosshair it can work perfectly at that distance, then walk upto a wall and shoot, and the bullet does it's job and lands below the crosshair.

I think there's a lot to be said for forgetting convention and just coming up with a method that suits your game. I'd like to see a super-realistic FPS like Operation Flashpoint, I'm sure that let you adjust the scopes and stuff like that. Thing is, it's actually easiest to have bullets come straight out of barrels, disregarding crosshairs and whatever. In DBPro you can add a bone at the start and end of your gun barrel, and you have perfect bullet trajectory calculation with just the limb position commands. I would probably just use the limbs/bones and when using ironsights, just raise the camera a little and use the barrel - I think people would get used to that before long.


Health, Ammo, and bacon and eggs!
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 20:16 Edited at: 10th Aug 2009 20:17
Quote: "If you put the crosshair where the bullet will land it becomes a nightmare to peek around corners as the crosshair jumps as you leave the corner"
, yeah, yet I still don't understand how to vissually do any of this, so far sid sinister has brought up a point:
Quote: "the bullet never leaves the chamber"
And that's true, for in many games the bullet never really leaves the barrel. Like Errant AI's guns for FPSC in TGC Store, http://www.youtube.com/watch?v=ZgvVa7jnT48, he fires from the hip, aims through the dot sight thing, and when he fires the bullet goes exactly where you're aiming, yet the bullet never really is shown, neither is a small thin line for the bullet shot. Thing is that if in a game you were being sniped or attacked by another player, and the if the player missed a few shots, you would see small thin lines going past you, which help you locate where the player is shooting you... I see that if you never illustrate that in the game the bullet never leaves the barrel, then you can get away with the crosshair and iron sight tactic, as you could just make the little rubble or spray of blood or bullet hole just appear on the next object the crosshair or iron sight (which are basically another view of the crosshair). Yet, that one little thing (The thin line to illustrate where the bullet is coming from) is still confusing,, Maybe when you fire the gun, the little explosion or flash of shooting the gun is ussually large enough to hide the fact that the line is coming from the iron sight, or near it (the larger version of the image is attatched
):
-------------------------------------
KEY:
-------------------------------------
[/center]
The Black Line = the Iron Sight's aim
Yellow Line = Aim of Barrel
Red Line = Middle of Yellow Line
White Line = The visible gunshot line that players can see when you shoot a gun in a modern day game
Other=Gun, gunshot, or background from blender
-------------------------------------
What else I also noticed is that the player who fires the gun doesn't see the thin line that is made from the gunshot to illustrate where the bullet went, only other players. I think it's because maybe that the player is closest to the gun, then the player would notice this effect, but other won't... I don't know, just a theory . (sorry if I made any typos, I'm in a hurry to go somewhere)

Attachments

Login to view attachments
Azunaki
15
Years of Service
User Offline
Joined: 11th Feb 2009
Location:
Posted: 10th Aug 2009 20:21
when you fire the gun wont stay were it is so in actuality the line just needs to be from in front of the barrel it wouldn't matter if it actually came from the barrel or iron site.(you could always have an algorithm to go from the barrel to the were the bullet hits if you care about it so much.

and yea that's probably true. it wouldn't really matter if they saw it or not. because like you said its for other players to be able to locate them not for them to locate themselves.

[url]http://myportfolio.x10hosting.com/[url]
visit my site.(still in progress)
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 20:26
Quote: "when you fire the gun wont stay were it is"
Yeah that was a posibility I thought of back in this forum a while back, that is if you're saying when you shoot the gun the recoil from the gun makes the gun move up so the barrel is aimine where the iron sights were originally when you shot the gun. Yet, there are other things that don't have much recoil, yet work... Algorithms, algorithms...
Azunaki
15
Years of Service
User Offline
Joined: 11th Feb 2009
Location:
Posted: 10th Aug 2009 20:29
what i mean by that SJH is that the gun's barrel wouldn't be were the line started any way because of the recoil. yes some guns don't have much recoil but a sniper is the only thing that most games put a line on to locate were your being shot from. from the players perspective when he shot any line made wouldn't be visible from the barrel any way(or shouldn't at least) and yes algorithms (kinda what makes a game a game)

[url]http://myportfolio.x10hosting.com/[url]
visit my site.(still in progress)
Pbcrazy
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: ...pillow room...
Posted: 10th Aug 2009 20:59
On real guns, usually, the bullet has already exited the barrel and hit the target before you even feel the recoil. For games, the recoil is displayed/happens after the game has already decided where the shot will land and has calculated everything else. Recoil won't matter during the current shot, it merely throws the aim off for the next shot.
Azunaki
15
Years of Service
User Offline
Joined: 11th Feb 2009
Location:
Posted: 10th Aug 2009 21:21
yes i understand that but what im saying is that any sort of line made from the bullet wouldn't be seen out of the barrel for the shooter because of the recoil... the recoil would move the gun so that it would appear more below it. (does any one understand what im saying?)

[url]http://myportfolio.x10hosting.com/[url]
visit my site.(still in progress)
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 10th Aug 2009 21:30
The guns in games cast an invisible line to the nearest object, then runs impact protocols, (decal, destruction, etc, etc). In ironsighting, all that happens is that the accuracy increases, and the ironsight is centre-screen, like the crosshair...

Those shot lines, or "tracers", are normally just an extra effect added to increase realism, and don't affect the ironsight at all...

If I was ever given the opportunity to remove all the bad from the world, I wouldn't, because for there to be heroism, compassion and all that is good, there must also be all that is bad.
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 21:30
Quote: "On real guns, usually, the bullet has already exited the barrel and hit the target before you even feel the recoil. "
Oh Duh! How could I forget that, I mean, the recoil comes from the the bullet being shot... hmm... In a game the player never sees the line of shot from the bullet, so putting two and two together makes it an algotrithm (yet again, no pun intended), meaning as long as there is no line of fire, the object in the crosshair or the line of aim for the iron sights will just have a bullet hole or spray of blood, or something, therefore no complex algorithm is needed, and the the entire aiming process works fine. Yet, that little line of the gunshot is what puts that nice effect into the shooting proces off the game... the way I see it, the only people that will have this complicated line effect from the aiming from the iron sights or using a crosshair are the players. The computer players can just aim as if firing from the barrel, I mean it's not like you can see the computer aiming the gun in First Person View and all that, so the computer's line of fire will be one/a few simple algorithms, yet for the player it's going to take somet thinking outside the box... I'm going to go check a professional game again to see how they do it. A friend of mine has a 360 and Halo 3, and seein as Halo has the "theater mode" option, It will let me observe the line of fire perfectly, as in see if the line comes from the barrel and goes where the cross hair is. I'll get back to you guys on that.
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 10th Aug 2009 21:40
The AI normally work by raycasting as well, like the player, and they will normally have recoil animations, decals, tracer rounds and such as well...

If I was ever given the opportunity to remove all the bad from the world, I wouldn't, because for there to be heroism, compassion and all that is good, there must also be all that is bad.
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 22:03 Edited at: 10th Aug 2009 22:15
(Larger image attatched)
Ok I'm back. I got the picture. I noticed a few things also, but first about the picture. First, if you look, the bullet line didn't even come from the gun at all. My guess is (since halo doesn't have an iron sight aiming process, but it works the same way as the crosshair process) it shoots the line of fire from the crosshair on the player's screen, and goes forward, so technically the line of fire comes goes where the gun is aiming. That, and in first person view, the explosion from the gun firing the bullit looks like it is touching the beginning of the line of fire, so it looks natural, but really isn't. Also, in some of the guns, when you shoot, the player flails the gun around , so the bullets are scattered around the place where the player is aiming. Otherwise, I guess you guys are right, the line of fire doesn't come from the barrel at all. The fact that they include stuff like the mini explosion from the gunshot, along with the character flailing his/her aim around with the recoil of the gun, (and the fact that these lines of fire last for split second) makes the character seem like he/her is shooting the line of fire from the gun. Otherwise, in games like COD, the firing is more accurate. I guess there are several and more accurate ways to do it, but at least I get it now. I'd still appreciate it if anyone told me more accurate ways of doing this, but otherwise I do understand the process. EDIT: Oh yeah, and from what I can tell, firing from the hip is less accurate for that line of fire, and aiming through the iron sghts is more accurate, because in my guess firing from the hip makes the gun diagonal from the crosshair, which aims straight, and aiming through the iron sights makes the player move the gun to the center of the screen, so in other words, the iron sights become the crosshair, and the player just moves the gun to the center of the screen, which basically makes it so the curve from the gun, to the crosshair, to the straight line to the object you're shooting at (when you fire from the hip) much more straight. Honestly that's what I think the iron sight aiming process is for. True, when you shoot a gun, you tend to aim through the iron sights, so in a sense it adds a sense of realism to the game. And the people who make games with iron sights sort of cheat, as in they make the crosshair bigger so aiming is harder for the player, and when you use the iron sight, the iron sight itself is small, so aiming is more precise. Its best illustrated when trying to "no-scope" some one with a sniper, compared to actually aiming through the scope and shooting them.

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Aug 2009 22:19
Most game have proper speeds and trajectories for bullets, like a line collision check moving through space at high speed. This is why if your sniping a moving target, or shooting a plane in an AA gun, you have to aim a little in front of the target so it meets the bullet.

I would guess that a bullet gets it's previous and new location checked, if it hits a solid object then the trajectory is shortened to suit - then that is checked for character collision. It's what Sparky's collision dll was made for . With sparky's you can leave decals, detect if the collision is against a solid object, metal could deflect bullets, fabric could let bullets through etc etc. Last time I messed with this I just sent 10 bullets with slightly skewed trajectories for shotgun bullets. Sparky's even has the bounce vector for things like grenades, along with DarkPhysics DBPro is pretty well kitted out for this sort of game.
It's easy enough to add a tracer to a bullet when they are handled like that as well, just stick a particle along the trajectory and stretch it out.


Health, Ammo, and bacon and eggs!
SJH
16
Years of Service
User Offline
Joined: 19th Oct 2008
Location:
Posted: 10th Aug 2009 22:34
Quote: " This is why if your sniping a moving target, or shooting a plane in an AA gun, you have to aim a little in front of the target so it meets the bullet."
I'm not sure, I mean in games (mainly MGS4 Online), I always predict where the person is going, or just follow them with the sniper's aim, and then when I get ahead of them by a little, I shoot, and most of the time they run into the bullet. But your right about the fact that they calculate the speed of the bullets. in MGS4, mainly in online which I do it, I use the mk.2 pistol, which is a tranquilizer. Its bullets are actually very slow. Depending on the distance from the enemy player and the gun, you have to aim ahead of the player. Like if you're aiming a football field away from the enemy, you have to predict where they are going, and aim for their head about a meter or more away from the enemy's current position, all depending on you're prediction on where the enemy will go. If you can get the ENVG (Enhanced Night Vision Goggles, which are actually more of thermal vision then night vision) you can see the bullet of the mk.2 pistol being shot. I mean, it is very slow, you can see the bullet, while compared to machine guns and other guns, the bullet is ussually a line that goes away in a milisecond. It takes about a second for the bullet to reach the target, givem that the player is about 20 meters (in the game) away from the target. Either way, you bring a good point, yet your point sounds more like how they get the gunshot to go where it is, ratehr than the line of fire. Don't get me wrong you did give helpful advice, just not the kind this thread is about, though it is closely related to the topic of this thread.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Aug 2009 15:52
It's all the same thing though - I mean a crosshair is a point along the bullets trajectory, an ironsight has to work the same way. Really how you handle ironsights is all down to how you handle bullets, at least in regard to their accuracy.

In terms of coding practice, to handle ironsights and crosshairs, I'd use the 2 limbs on barrel idea, then position the camera at the start of the barrel and point it towards the end of the barrel. This gives a perfect trajectory that is ideal for sniper rifles. Then using this trajectory I'd move forward along it by a suitable amount for the guns range, and use that screen location for the crosshair. You could even make a crosshair object, position it at the start of the barrel, point it towards the end, then move the crosshair object forward by X units and you have an accurate crosshair. For ironsights I'd do the same with the camera, then move the camera up and back a little. With ironsights, I'd have an animation for that which brings the weapon into the middle at eye level.

When I did this before I would have the weapons center when using ironsights, works pretty nicely and is easy enough to do. One thing though - try and avoid gluing weapons to hands, it's much better to have your hands and gun as 1 bone animated model, then this can be positioned and rotated as if it was the player. It depends how much of a simulation you want it to be, but it is quite beneficial to be as realistic as possible - just because he's missing a few vital limbs, in fact he's arms and a gun, does not mean he's less of a character - I hate when people just stick a gun on the screen.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2024-11-25 01:45:56
Your offset time is: 2024-11-25 01:45:56