Does anyone know of a definitive list of weapon parallax solutions for FPS’s?

Weapon parallax meaning your cross hair is in the dead center of your screen, but your weapon is in the corner, so when you shoot it comes out of the weapon but find its way to the center.

I think doom 2016 shot projectiles out of the model, then moved it gradually to match the center of the camera view.

most raycast guns just shoot from the camera center and the model just does muzzle flash.

and in quake three The plasma gun initially jumps 30 units before turning into a ball.

Any other suggestions?

edit: oh, and the original serious sam cast of Ray from the gun and moved the cross hair so where the ray hit.

Just have the projectile move towards whatever is actually at the center of the screen.

Does Doom 2016 really “move it gradually”? That would mean projectiles follow a curve, which doesn’t sound right to me. I played with the weapons in the middle of the screen for the old-school vibe, though, so wouldn’t have run into it.

1 Like

It’s fine to decouple the effect from the actual collision as well if that help - the two will usually converge before a problem.

3 Likes

Is there any reason you can’t just aim the particle at the target?

2 Likes

I’m positive that’s what the rocket launcher does. If you try it out the rocket definitely starts at the launcher, then moves towards the center of the screen.

That’s what I’m initially testing. But I’m keeping the collider/ray on the projectile leaving the barrel.

I’ve done this before, and it makes for some janky mechanics. It’s fine if its instant, but for something like a rocket or a plasma shot it can result in the projectile not shooting straight.

Do you have an example of it “not shooting straight”?

In comparison to the size of the areas / obstacles / targets in most FPS games the parallax error usually isn’t particularly large, and it’s also exactly a thing our eyes and brains deal with every single day.

Yes, but with perspective that will happen with any object moving in a straight line in the direction the camera is pointed.

Edit: It’s one of the fundamentals of perspective drawing.

lol, yes I know how perspective works.

I’m telling you, it shifts up and to the left to the center of the screen for the first 10 or so feet, and settles on a path that is straight out from the camera.

I just loaded Doom 2016 and tried it.

Here’s a screen snip showing the hit point of the Plasma Cannon clearly being on a line between the end of the gun and the crosshair. There’s a bit of scatter so the exact hit point varies, but it’s clearly off-center and more or less matches the percieved end of the gun.

7618642--947131--upload_2021-11-1_12-42-47.png

Here’s a snip of me standing still and firing. And as far as I can tell it’s just obeying the principles of perspective drawing. The projectiles always seem to be below and right of the crosshair until they reach it.

7618642--947134--upload_2021-11-1_12-47-2.png

The projectiles seem to spawn at some point a short distance in front of the gun. There are then layers of effects - recoil, camera shake, muzzle flash, smoke - which pretty effectively obfuscate the exact position… usually.

One case where it doesn’t hide the spawn position effectively is where I was experimenting with the rocket launcher, standing against a wall which was covering the right half of the screen. The gun animation pointed sideways, indicating that I was obstructed. If I fired anyway the projectile spawn point was moved significantly and obviously to the left. The same happened with the plasma gun. As a result, the first projectile fired appears to spawn off-screen to my left. Importantly, even when they do this, they still travel in an apparently straight line towards whatever the crosshair is pointed at.

When I stand near a wall that obscures the left side of the screen, the gun shows as obstructed and pointing to the left, and hit marks on the wall appear to my left.

So, as far as I can tell, their solution is to simply spawn the projectiles in front of the gun, and point them at whatever the crosshair is centered on. I can’t conclusively rule out further subtleties, such as a curve in the trajectory, but I also can’t see the need for them - there’s enough visual obfuscation going on, and the deviations are usually small anyway. Don’t make your solution more complex than it has to be.


Actually, your weapon’s muzzle isn’t really that far sideways of the center of the screen. I just measured in Doom. It’s significantly less than 300px off center at 1920x1080. And our eyes / brain are used to making sense of exactly this kind of thing, every single day.

Basically, I don’t think the parallax problem is as big as you seem to think. Start by just pointing the projectile at whatever the crosshair is centered on, then test your game. You can always revisit if it turns out to be an issue.

4 Likes

Now I need to go and reinstall soon to recheck this.

I actually at one point did a snaps level specifically to dissect how they do things and I was sure the rocket moved over.

I really appreciate you taking the time to do this.

As for aiming at a raycast from the center, I’ve tried this before and did not like the results at all. Things got weird at close distances.

The definitive way to see if there’s a curve would be to get one player to look directly down on the firing trajectory of another in multiplayer.

The rocket could be different. Most of my testing was with the plasma gun as it’s easier to see, since it’s lots of bright projectiles animating along their trajectory. The rocket is just one projectile, not as easy to see, and mostly covered up by the recoil animation.

By the way I think the initial jump (which I have already in the code) is a carry over from Q3.

I also implemented moving over the projectile to the “true point” like I was talking about and the curve is almost impossible to see.

The only issue is the path turns to pure jank randomly. I’m sure it has more to do with my trash code, but I’ll figure it out.

That’s why I suggest lerping between that and just plain forwards over some short distance in front of the player. If the projectile clearly shouldn’t get to the crosshair location then just do something that doesn’t look wrong.

Though Doom seemingly isn’t even bothering with that, since a gun pointed left still fires a projectile where I’m looking. The thing is, to a player that’s not a problem. The visuals and speed of the action cover up the angle difference most of the time. I’ve played hours of the game and I only found that awkward edge case because I got carried away experimenting to answer some question on an internet forum. :wink:

1 Like

Ha!

Yes, I do love to nuke things.

When I implemented this stuff quite some time ago, I think the reason I had an initial offset (ie: a “jump”) was purely to ensure that the projectile spawned far enough away from the player to not interfere with other stuff.

Which is why I said I couldn’t rule it out. But… if it’s “almost impossible to see” then what problem is it solving? It’s giving you more work, and making your projectiles less predictable at short range, all to make a difference that’s “almost impossible to see”.

There’s plenty of stuff you can do with your game which will take less effort and be very easy to see. Do those things instead. :wink:

I was wanted to see what other options there were that I hadn’t thought of.

1 Like