Sign in to follow this  
moeen k

how to make bullet that is shot from a gun to wo same point and direction that HUD has pointed

Recommended Posts

 

I think it has an standard solution for most of games but I don't know it. in many third person games I can really see the bullet came out of the gun but in most of tutorials I just see the gun just has a muzzle flash and bullet hit is raycasted from center of camera.

how can I make a gun that is moving by many character animations move to same direction of screen HUD? I'm focusing on third person game butt I think issue is in fps games too.

 

thank you for helping.

Edited by moeen k

Share this post


Link to post
Share on other sites

I'm not sure what you're asking, so I'll give a few variations in my answers.

If you're looking to move the targeting point, many games use a reticle (a crosshair icon) to show the approximate point of impact. It can move and wander as the player travels the world. It can also scale large or small depending on the accuracy and type of weapon.  Exactly where it points can be adjusted either by code or by animators, depending on your game.  Some games will also add some random motion to it, both to help avoid aim-bots and to simulate that humans aren't generally accurate marksmen on the battlefield.

As for where the raycast source happens, either from the center of the screen or the muzzle of the displayed model, in general that doesn't really matter. In most first person games you see other players as human-shaped avatars, but based on what you actually see in the game your head would be mid-torso and arms are rooted somewhere behind your back.  So fire the bullet from whatever position relative to the character's root works best for the game.

Also for first person games, usually the player does not see their actual in-game model that other players see. Their own character is invisible and only their arms and weapons are visible, if they're shown at all. 

Some games don't use a single raycast, but are processed over time as segments. Bullets in real life take time to travel, and in networked games that time means more opportunity to mask network latency. A quick six-frame animation buys 90 milliseconds. A traveling bullet may add another 10 milliseconds to travel.  To a player the slight delay can feel like added realism. To the programmers that slight delay lets the developers hide a round trip to the server. It also allows for players in motion to potentially react and avoid a shot, or for players to need to track their shot to hit where the opponent will be instead of where they are.

And if you're talking about how you keep your animations matching the screen, that's usually a simple matter of parenting your animations to the camera, or parenting your camera position to the same root as the character.  For most good art packages it is a simple thing for artists to address.

Share this post


Link to post
Share on other sites
49 minutes ago, frob said:

I'm not sure what you're asking, so I'll give a few variations in my answers.

If you're looking to move the targeting point, many games use a reticle (a crosshair icon) to show the approximate point of impact. It can move and wander as the player travels the world. It can also scale large or small depending on the accuracy and type of weapon.  Exactly where it points can be adjusted either by code or by animators, depending on your game.  Some games will also add some random motion to it, both to help avoid aim-bots and to simulate that humans aren't generally accurate marksmen on the battlefield.

As for where the raycast source happens, either from the center of the screen or the muzzle of the displayed model, in general that doesn't really matter. In most first person games you see other players as human-shaped avatars, but based on what you actually see in the game your head would be mid-torso and arms are rooted somewhere behind your back.  So fire the bullet from whatever position relative to the character's root works best for the game.

Also for first person games, usually the player does not see their actual in-game model that other players see. Their own character is invisible and only their arms and weapons are visible, if they're shown at all. 

Some games don't use a single raycast, but are processed over time as segments. Bullets in real life take time to travel, and in networked games that time means more opportunity to mask network latency. A quick six-frame animation buys 90 milliseconds. A traveling bullet may add another 10 milliseconds to travel.  To a player the slight delay can feel like added realism. To the programmers that slight delay lets the developers hide a round trip to the server. It also allows for players in motion to potentially react and avoid a shot, or for players to need to track their shot to hit where the opponent will be instead of where they are.

And if you're talking about how you keep your animations matching the screen, that's usually a simple matter of parenting your animations to the camera, or parenting your camera position to the same root as the character.  For most good art packages it is a simple thing for artists to address.

can you explain a bit more? I'm just saying : I'm working on a third person project. I have a crosshair in center I'm my camera and character with a gun in front of it. I want to simulate bullets instead of ray casting. so bullet that released with direction of camera hit where player aims with his crosshair.

as character gun and camera are in different places,i think technically its not possible and developers use some trick to show bullets. like bullets just getting instantiating and game calculates result of raycast as aiming result. 

another question: I think you are one of this website managers. with  new changes(I don't know what realy is- maybe google restrictions) I cant open website from iran and I'm using vpn. I hope  solve the problem.

Share this post


Link to post
Share on other sites
On 6/25/2017 at 4:56 AM, moeen k said:

can you explain a bit more? I'm just saying : I'm working on a third person project. I have a crosshair in center I'm my camera and character with a gun in front of it. I want to simulate bullets instead of ray casting. so bullet that released with direction of camera hit where player aims with his crosshair.

In that case use your camera's Forward vector, and the camera's position. That is the direction and position to fire from.

On 6/25/2017 at 4:56 AM, moeen k said:

another question: I think you are one of this website managers. with  new changes(I don't know what realy is- maybe google restrictions) I cant open website from iran and I'm using vpn. I hope  solve the problem.

No, I'm not one of the administrators. Moderators are regular users who have been granted some extra buttons to move topics around and to block spammers and such.

I have no idea how your VPN system is set up, or why it might be having problems.

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