PlayerViewPoint should not be where you fire the gun from

The more I tried this out, the worse the idea got. Bullets ideally should come from the end of your gun barrel and not the player’s view port or the camera manager or anything of that sort. Here’s why: Look up and fire your gun. Your gun is pointed forward but your bullet went up, makes 0 sense logically. Unless your viewport is tied to your gun’s direction, this won’t work well because the gun will never hit what the gun is pointed at only what the player is looking at.

This is also a screenshot of what happened to me:

Because my camera wasn’t offset by the character and was standing directly behind the character, the bullets would have just hit the character mesh. So to fix this, I had to go to my Collision settings and change Bullet to Ignore on the Character Mesh. Now I’m not firing at myself but through myself.

It’s an odd way to fire bullets to be honest. This only really works if your gun and the middle of the screen are aligned.

I felt the same way, and actually did two line traces. First one is the same from the tutorial, and I saved it as the CameraTargetHitLocation. Then I created a USceneComponent in front of the barrel and performed a second trace from there to the CameraTargetHitLocation.

This drew the trace from barrel to wherever the user was aiming.

I had some collision issues with gun, so the projectile spawn point is out abit (like 10cm). Ideally I’d disable or ignore collision with the gun, but the quick fix was good enough.

EDIT: I just realized you’d have the same issue with this implementation. But that’s fixable with a second channel for the camera hitLocation that ignores the player.

1 Like