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.

DarkBASIC Professional Discussion / 3rd person shooting aim mechanism

Author
Message
Aralox
19
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 5th Jul 2010 14:40 Edited at: 5th Jul 2010 14:42
Hey guys, Im making a shooter, and am going for the method of using a raycheck between the player and an aiming plane for shots. Ive got my aiming plane all set up in 1st person view, i.e. the crosshair lines up nicely with it, but im having troubles with lining it up in 3rd person view. Im not sure how to go about it, but i want to achieve the same effect star wars battlefront 2 does with its shooting (http://www.youtube.com/watch?v=Z85p4_nhXys). Any help would be appreciated.

PS: I think Cybermind had the same problem i had, but his issue wasnt solved. ( http://forum.thegamecreators.com/?m=forum_view&t=86817&b=1 )

EDIT: ahh whoops wrong youtube link - heres the right one: http://www.youtube.com/watch?v=ChwsFDg8FVk (swbf2 gameplay vid)
I left the other one because breakbot is awesome

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Jul 2010 17:22
One thing that might be worth considering is more realistic bullets, probably more realistic than Battlefront.

See, the weapon there could have a limb at the start and end of the barrel, then any bullet fired could follow that exact trajectory, giving it incredible accuracy. The problem is that people might not like that, they might prefer a big X on the screen where every bullet hits. You could position a plain at the start of the barrel, point it at the end of the barrel, then move it forward X units, then orientate it with the camera. You'd have that sort of effect, only the guns movement would be very relevant, when reloading the barrel reticule would jet off. Now this is a side effect I've used in the past - for instance I had a FPS where the shotgun gets reloaded shell by shell, but if you left a shell in there, you could fire it while reloading. So, you'd be running around, reload the shotgun and the reticule would end up at the top left, then if an enemy appears, you just use the reticule and fire off that shell.

I liked it, made the game feel really accurate, but I know how some people can be.

Another option is to do that - but have the shooting pose and calculate the angle offset on X and Y of the aim - then stick the reticule there the whole time, like the reticule angle from the shoulders, so you can use that to show the aiming reticule no matter what the character is doing, and as long as the animation goes to the shooting anim, it should work just fine. That would give a less bobby reticule, would be very accurate, should keep everyone happy.

It's vital that every weapon has limbs at the end and start of the barrel, take away the guess work and make it awesome. By awesome, I mean adding effects and stuff from the barrel of the gun and stuff like that. A lot of people guess this stuff, all for the sake of adding an extra limb.

Now, for aiming itself - well your character would need a pose, maybe just the torso gets a pose for aiming the gun, so the legs can be animated indipendantly. Anyhoo - that's why you use the shoulders, or should I say, the bone inbetween the shoulders - because that way you can rotate the same bone on X to aim up and down, and rotate the torso bone (base of spine maybe) on Y to aim left and right. The mouse movements X and Y can be applied to these bones.

It's all doable, it just takes some patience to get things rigged up properly.


Health, Ammo, and bacon and eggs!
Aralox
19
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 5th Jul 2010 19:25
Thanks for replying Van B . I really like the super accurate gun idea, but how would the reticule work? What i mean is that since the gun is pointing at an agles to the view, where on the bullet path would you draw the reticule? This is the crux of my problem with the 3rd person view aiming. Here is a picture showing you what i mean (yes, gun just ripped off a cs screenie. the reticule is at the centre)


(i wonder how counterstrike did it)

What I did (in 1st person view) is I placed the aiming plane directly in front of the camera so it will always fit the crosshair no matter how far away it is, so the player will know exactly where they are shooting (if the shot/raycheck is made from the centre of the camera, it would be slightly different if it's made from the gun). Im not sure about how good this system is.

When you say adding effects to the gun using the two limbs at the start and end of the barrel, do you mean like making shot particles come out of the barrel in the exact direction its shooting in?

Ive worked out a pose system where the character's y rotation determines the gun y rotation, and the character's arms/head limb determines its x rotation.

Attached is my code and media so far, press v to change the view, and hold down control to fix the camera so you can see the guy walk around. Sorry for the slightly messy code (and quite messy post =P)

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Jul 2010 20:35
Hehe, can o worms huh!.

When I did it, I just moved the reticule forwards, as if it was a bullet firing from the gun - so it might not be dead centre. To compensate, I added nice iron sighting, so the gun comes into the centre of the screen for an accurate shot.

If you think about it, CounterStrike does it wrong. There's no magic bullets that appear from between the players eyes and follow a direct trajectory. To me, it's more noticable when you stand in front of a wall and check where the bullet ends up - accurate games have the bullet come right out of the gun, wheras more arcadey shooters often have that middle reticulte thing.

In reality, people just don't run around with their gun in their right hand like that - it's put there to keep it out of the way, really the gun would be in front, in the middle in a real situation. I suggest ignoring CS, and trying to work out gun poses for yourself - watch shooting videos on Youtube (gun people like to show off their guns). I mean, an UZI for instance would be held quite close to the chest, maybe to the side a little - with accurate shooting that would be absolutely perfect, but in CS it would probably be hanging at the side like it weighed a ton. You have the added problem of third person, so you need something that works well in both. Can you imagine the CS gun in a third person?, the head would have to be hanging to the side, sorta twisted back, as if one shoulder was heavier than the other. Even looking at that screenshot, you can tell that gun isn't centred well. Would you aim and fire a rifle without looking down the sights?

If you have any nephews, kids, relations who have decent sized toy guns, airsoft guns, anything to reasonable scale I suggest borrowing some and working out how you would hold and aim them. I actually bought a few plastic airsoft guns just for modelling. The time it saves is worth a few bucks for a cheap gun, some of them are actually quite well reproduced.

Not that I dislike CS, it's awesome, but if you want realism, then CS gun poses are not a good idea (unless your shooting someone in the kidneys).

Your right with the particles idea, you have that 3D location to spawn particles from, smoke etc, and also glue a gun flare, then show it for 1 frame when shooting, would look awesome and might only need just a plain. I would rotate it randomly on it's axis each time. You could even eject old shells, by adding a limb to track the position where the shells should eject. Really, with DBPro it's a matter of preperation, then you can emulate how the gun works exactly, how it's held, fired, and reloaded. It's good fun to work like that, very rewarding to have an awesome, accurate gun shooting 'real' bullets.

I'm a fan of having right click act as iron sights / scope, like have the gun flop about, have it at the side - but then bring it to the centre before firing - if the player is running when firing then what you get is free, 'accurate' running shooting (all over the place). Might be the way I play FPS games though, I prefer to sculk about and go for head shots, rather than run in guns blazing.


Health, Ammo, and bacon and eggs!
Aralox
19
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 6th Jul 2010 07:02
I know what you mean about skulking around sniping, i love it. I had another look at cs guns, and i realised that the first person view of the gun is unrealistic, but the model of the character holding the gun is realistic. This means that there must be two different models, the realistic one everyone else sees, and one just the player sees, which is offset to the corner. I always thought that first person involved the same model, just with the character's body hidden and the camera placed at the head area.
Would I be right in saying that they do this because it would be dificult to actually aim the gun when its held realistically, i.e. it takes up too much of the screen?

I think working out gun poses would be really important for modelling the character that everyone else would see, so ill try that with my...uh i mean nephews *cough* airsoft shotgun.
Im not sure, but it could be that the gun barrel of the character model is lined up with the crosshair, so the bullets are actually coming out of the gun, therefore it looks realistic to everyone (but yourself).

Im not too confident about particles, as ive never used them before. Ive got a good idea of where to start with them now, but I guess ill jump into them when the time is right, when ive got my shooting system down pat. Could I have a look at your shooting game if youve still got it lying around somewhere?

Ahh i see where youre coming from now, the gun isnt actually meant to be accurate when the iron sights arent used, so the reticule is just a vague indication of where the bullet might go. That is realistic.

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 7th Jul 2010 02:34
Well I take another approach that is rather simple for accurate aim. You first raycast from the camera straight forwards until you hit an object. Then you take that position where the raycast collided and point the bullet at it. That way your crosshairs will always be perfectly on target when they are centered on the screen. To add a little unaccuracy, just add a random number to the position where the camera's raycast hit an object. That way you can alter the accuracy to your liking.

If it hasn't exploded yet, I haven't touched it.
Aralox
19
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 7th Jul 2010 08:15
Hey thats a good idea too - its like van b's reticule, but placed at the point of collision so you have accurate aiming without iron sighting.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Jul 2010 09:22
I was just gonna suggest that Aralox, that way there will be none of the usual shooting walls even though the reticule is aiming over it - that annoys me and is something we see in most FPS/TPS games. Would look great with a laser sight too, just stretch a ghosted plain to the collision point, scroll a smokey red texture through it, and add a little red dot at the end. Maybe to be really unique, don't even have a crosshair reticule, just have a laser sight, iron sights, and scopes - more realism if that's what your after. It doesn't harm Killing Floor at all, in fact it's satisfying to get a good head shot with no reticule. Most weapons can take a laser sight, might be a bit of USP for your game to go that route.

With a sniper rifle, I had the iron sight mode zoom the scope into the camera then switched to using the barrel itself, tweaked the FOV, positioned the camera at one end of the barrel, point it at the other, and hide the rifle. Then theres no need for extra cameras etc which can slow the entire game down. I tweaked the FOV a bit in all the iron sights depending on the range of the weapon, have it smoothly go between FOV's - I think the default is 66 or something like that, even just using curvevalue would keep it nice.


Health, Ammo, and bacon and eggs!
Aralox
19
Years of Service
User Offline
Joined: 16th Jan 2007
Location: Melbourne
Posted: 7th Jul 2010 10:59
Wait do you mean that since the reticule is accurate, on the point of collision, its annoying? or do you mean that lack of this?

I think ive decided on the gun system i'm going to use, and its going to be similar to l4d and cs. I like the idea of models looking realistic as they shoot (how it looks to other people), but also the convenience of shooting using a view with the gun in the corner and a centred crosshair where the shot always goes. I think, at this stage anyway, that ill stick with player convenience over realism. (ive mentioned this before, but if you think about it, it is realistic to everyone but yourself)

Laser sight positioning would therefore be simple for the model everyone else sees: like you said i would just stretch the plain (along the gun barrel) to the collision point. I wasnt sure how to pull off laser sights in the player's view, so i had a look at how l4d did it. What they do is they have a short plain coming out from the gun, and a red dot at the crosshair, so you dont see the whole laser. After some fiddling, i found that the red dot was caused by the real model, and the short laser in the player's view did not change, and was angled to point to the centre of the screen so it always looked right. (i found this out by moving to pick something up, where the player reached out their hand causing the gun to angle off to the side. the middle dot would then go places not in line with the short plain sticking out of the gun.)

Just to help you visualise what i mean, i got some screenies
Laser sight, lined up:


Laser sight, skewed:


I dont mind the misalignment caused by the skewing, its a small price to pay for convenient shooting and realistic models.

Thanks for the suggestion for the sniper scope, i will definitely use that.

Login to post a reply

Server time is: 2026-07-25 08:11:55
Your offset time is: 2026-07-25 08:11:55