Muzzle direction to bullets' flight path

my game is third person shooter, for game design reasons I have decided to use geometry bullets…at present in “normal mode” bullets are fired in the camera direction… I am also trying to have my hero aim at and attack two targets simultaneously while duel wielding guns and other weapons…I think I can more or less figure out throwing weapons, but I cant quite figure on a way to let the guns muzzle direction be equal to a bullet’s trajectory when a shot is fired.



any ideas



also



how to find an angle where the plane of the angle is always going across a character models facing direction and origins at each shoulder… errr hope I explained that right



again ideas if any

Set the bullet rotation to gun rotation? Doesn’t sound complicated to me.

Make sure you create the bullet where the gun is too. It would be silly for the bullet to appear at 0,0,0 going in the direction the gun is facing, just like it would be silly for it to go the direction the camera is facing.

@valentiinro said:
Make sure you create the bullet where the gun is too. It would be silly for the bullet to appear at 0,0,0 going in the direction the gun is facing
, just like it would be silly for it to go the direction the camera is facing.


pretty much had bullet location figured out = attachment nodes and having the bullet travel in the camera direction will be natural in all but the special cases, now for my problem, I could just take the easy road and cheat a little since I already have control of the location from which the bullet leaves the weapon and just load an approximate arm pose animation and fire the bullet in the direction of acquired targets once the muzzle direction looks "close enough", but I also would like to "slow mo" things down a bit as "events" in the game and don't want bullets looking "too wrong" when they leave the weapon, there is also a fair bit of unconventional movement involved which could add even more issues............did find wezrules' math tut vid last night so I'm trying to come with something based on what learn there....we will see

one question though how to define a geometric sector in code..."no I'm not asking for code"......I have coded stuff based on explanations before............I want to define an area of influence that is always in my hero's facing direction that can be opened to a maximum of 180 deg or closed to a minimum of 5 to 10 degrees in his facing direction "across his chest"

its an auto targeting idea I have to allow for attacking multiple targets simultaneously once they are detected inside the area defined by the sector, but still give the player a bit of the fine control u get in free look mode

Oh, I think we assumed you were saying you knew how to aim the gun, but did not know how to get the bullet to come out of it right.



Aiming the gun is a bit harder, because it depends on more than just the character’s location, it also depends on the arm position and whatever. It’s pretty easy to get the vector and subsequently angle from the character’s position and the target’s position, but for realism, you definitely can’t have the arm aiming as if it’s from the center of the chest. I don’t know very much about shooting guns though. The game I am working on is more with machines, so it’s easier to plan out their movement, you give it a turret, and the turret spins.



What I would do is see if you can get the shoulder position, and then plan your arc from there, with the arm straight.

Alternatively, if they are shooting like a quickdraw cowboy, then you would aim the arc from the elbow, which they would keep near the hip.

I guess noone would really aim with the wrist because the recoil would probably hurt it pretty fast, so those are your two aiming options.



What kind of model are you using, do you have access to the locations of the joints and all that?

1 Like