Sign in to follow this  
Nanoha

Bullet starting location

Recommended Posts

Odd question, the barrel of the gun right?

The problem I have, is knowing where the barrel of the gun is (in world space). I'm using Ogre3d with a logic/view split. My player/monsters have a scene node, which has a model, which has a skelington, I attach guns to the palm. The guns also have some bones, one of which is the barrel (I use it to show the muzzle flash/attach rocket to an rpg). I Can work out where this is in world space but only on the "view" side of things.

I had a similar problem working out where the "eyes" are (Since its a camera attached to.. and so on). I solved that by creating a new type of Ogre object that works out its world position and sends it in my message system (It can then be attached like everyhting else). I then pick up the messages and deal with them.

I'm thinking about doing that with my guns but before I do, should bullets come from the gun? I play some games (fps) where if I can see something, I can shoot it - even though there may be a wall between the gun and the target (suggesting bullets come from the eye). Other games, even if I can see a target, if there is an obstacle between the gun and the target then it will hit that obstacle instead (suggesting the shot comes from the gun barrel).

My bullets are just rays but I also have an rpg which looks slightly odd firing from the eye (although making it start a meter away may look ok with all the smoke too). Currently I shoot from the eye and all is sort of well but my monsters don't have cameras and so think they are shooting from (0, 0, 0).

Comments, suggestions, criticisms and so forth all welcome.

One thing I will not do however, is to access my "view" directly, so no direct access to the pistols model or anything.

Thanks

Share this post


Link to post
Share on other sites
It's very common for FPS games to fire projectiles from the camera position, even though this means that the player is shooting projectiles out of their face...

It's kind-of a game design choice... If I was making an arcade game like COD, I'd go for the shoot-from-camera system, because it's not going to surprise the player at all. However, if I was making an immersive/realism based game, I'd find the barrel's position and shoot from there, even though it means the player will perform the dumb action of point-blank shooting at their own cover some times...

Share this post


Link to post
Share on other sites
Although I have got an fps right now, I'm planning to use all my stuff and make a top down/third person, aim with mouse type game (player shoots at mouse positions - think torchlight). So I am tempted to do it from the barrel of the gun.

Another question then, do I tell it where its pointing or do I tell it where its pointing at? If I'm aiming down the sights then it doesn't matter but if I'm just firing from the hip then I have a problem. If I tell it the direction its pointing, then it might be firing 30cm below wehre I want it to.

Share this post


Link to post
Share on other sites
You *could* cheat this -- you know roughly the pose of the player ("kneeling rifle raised to look down the sights" or "firing from the hip while running") probably for your server side hit detection.

You could just guess at the vector based on that information. It would be more accurate than just shooting down the camera view axis -- it would be good enough to be able to shoot blindly round a corner, for example.

It wouldn't be perfect, but it could be good enough for your purpose.


Another option is that presumably your server side code is telling the render code what poses to adopt -- not necessarily ALL the animation detail, but at least some of it. You could pass the weapon position/projection vector from the server to the client, the client coerces the animation pose to conform. This would neatly give you the ability to have working sniper scopes and laser dots and so on.

You'd have to carefully set things up on the server side but you have the backup that if the client animation just *can't* conform to where the server data wants to put the weapon, it could just lock out shooting.


A third option is that the client generates the fire vector (origin and direction based on the character pose -- you could just have two points in the model which are the receiver and muzzle and report those back from the animation) and includes it in the shot request. The server would still get to veto someone who is trying to shoot from an obviously illegal position (say -- 8 feet above their head (never trust the client)) but you'd get the view/shot calculation corresponding.

Share this post


Link to post
Share on other sites
Fortunately this is single player. I went for firing from the barrel. The difference between firing fromt he hip and firing while looking down the sights is barely noticable but my rpg now fires better.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this