A Problem in FPS Games

Hello, everyone. I have a problem not only in UE4, but also in all FPS games.
Usually in FPS games, the gun is on the right/left side of my body. When I press fire button, there’s a bullet shooting out from the muzzle. But I’m always aiming at the objects in front of my body. If now I’m aiming at a near object, there will be an angle between the bullet’s velocity(a vector) and my body’s forward vector. But if I’m aiming at a far object, the angle will become smaller than before.

One approach is to compute the vector from the muzzle to the aimed object in the moment I press the fire button. But if there’s another object appear in the path of the bullet before the bullet hit the target, things will be different.

So how can I achieve this like what Blizzard did in Overwatch (such as Lucio and Mei)?

I have no idea what Blizzard did in overwatch, but the usual solution is the most boring you can think of: Spawn the projectiles from the camera and not from the gun. This will not be noticable to anyone if the projectiles are small and fast enough, and will solve your angle problem. If you play some effect at the muzzle no one will notice.This is how CS GO and many other FPS do this.

If this does not satisfy you, please tell me what Blizzard did in Overwatch, because I don’t really know what mechanic you are trying to achieve :smiley:

I’m very grateful for your answer. Your answer help me a lot and I have tried this approach in UE4. But maybe there are some differences between CS GO and Overwatch. In CS GO, the bullet hit the target instantly when you press the fire button. The bullet is fast and small enough so that we can’t find its trajectory. But in Overwatch, some heros use their special weapons and shoot the special bullets, such as frostbolt. The bullet is not small so we couldn’t ignore and it hit the target after a short delay. I tried to spawn the projectiles from the camera but it looked very awkward. But in Overwatch, these all looks well: The bullets spawn from the muzzles, and we can see their trajectories, and they hit the targets correctly after a short delay. That’s amazing. I don’t know how to achieve this and I’m curious about what they have done. Thanks again for your answer.

Ok, so I just fired up Overwatch :D. And I don’t think they solved the problem at all.

The weapon of Mei for example is very close to the line of sight, so the real hit point (in your last drawing) is not too far away from the actual hit point.

Second, the difference between these two decrease over distance, so to have a real obvious dissonance, someone has to stand right in front of you, in which case you kind of expect a body shot anyways, so there is no problem. If an enemy is right in front of you they are also very likely to move very fast in terms of degrees, so you can’t aim properly anyways.

The third thing that makes this a non-issue: If you calculate the point the projectile should hit, someone moving into the projectile trajectory AFTER it has been fired is just very unlikely. I just tried it and it is hard to even get.

Fourth: The player does not expect the projectile to hit in his crosshair in this case. Just like in real live sniper tries to aim so that the bullet hits his crosshair lkine of sight right when it hits the target, he will of course not expect the bullet to hit exactly the line of sight of the crosshair prior to that point.

The most prominent example may be to stand in front of a wall that blocks your weapon but not your line of sight. It is only logical that your projectile will not go through the wall, eventhough you can see the opponent. No player will find that strange.

So all of this arguing is of course useless if this is a real problem for you. So my question is: is this a real problem for you? Do your projectiles not hit anything?

Thank you for your reply. You really help me a lot and now I understand what was wrong. I started learning UE4 recently so I used the first person template and modified some codes to implement some actions we saw from the FPS games we played (like crouch, speedup, etc). Then I found that the projectiles do not hit correctly in the template. I tried to solve this but I got failed. So I had this problem. You are right. As you said in the comment, the second case is very unlikely. Even if it really happened, the projectiles are not expected to hit the point we aimed at in that moment. I tested Zarya in Overwatch yesterday and found that the ray from her weapon did not hit the correct point when she was near the wall. Then I realized that if the enemy is too near, we have no attention to figure out which point the bullets hit, as long as they hit the enemy’s body. Because of the limit of the maps in the games, if the muzzle’s orientation is nearly same as the character’s, it would be right within a limited distance. Thank you for helping me to understand this. Thank you for your patience. It’s very nice of you. Best wishes for you!