Questions about First Person Guns

Alright, so I have a few questions about First Person guns. I’m pretty good with third person (at least, I’m inclined to believe so with the last gunkit I’ve made) and now I’m trying to move onto first person. Yes, I’ve read guides such as EgoMoose’s The First Person Element Of A First Person Shooter. I’ve already setup how to get the viewmodel in view of the player (parenting the viewmodel from the camera), though I have questions:

1.) Should I be using CFrame interpolation or keyframe animations? I’ve realized that keyframe animations don’t bode well when lerping the AimPart to the camera. This also brings me to my next question.

2.) How do popular FPS games (such as Phantom Forces) work the reload animations of the guns? I’m especially stuck on this part, since manually CFramed arms don’t really allow for keyframe animations.

3.) Where should the raycast origin/projectile origin be from (client side)? Should it be from the viewmodel’s literal barrel or from the camera’s CFrame?

Any and all help would be appreciated!

3 Likes

Most games combine the two. 2 animation loaders, of which one is in the weapon itself to handle the bolt, the second one in the “fake arms”.

The magazine is welded to the weapon when not reloading, to the hand when it is. You can either re-weld the same model, or create a new one to visualize the old one getting thrown away.

To align the sight, you interpolate the entire model (fake arms + weapon).

As for the origin. Games such as Counter Strike make it come out of the camera to remove the need to check whether your weapon is obstructed. PF makes it origin from inside the weapon (not the barrel’s tip to avoid missing when close to target or shooting through walls).

6 Likes

I’ve done this with my other gunkit… of course minus the CFrame part to aim. I’ll give it a try and incorporate it with the FPS system I’m making. Thanks for your input!

And for the origin part, I think I’ll go with it coming out from the head to try and have an easy way to avoid wallshooting.

As for aligning the weapon, how should I do this? I know I’d have to have the AimPart move to the camera but I’m kind of confused on how I would have it move the whole model. Nevertheless, I’ll give it a shot.

1 Like

Some people used spring constraints, but I’d rather use welds as it gives you more control. Change the C1 value by combining different movements. A simple offset for movement velocity, a swing when walking, a recoil when shooting and a knockback due to suppression.

Also forgot the base offset depending on whether you are aiming down or firing from the hip. You store the target CFrame in a script and interpolate the true CFrame to reach it.

1 Like

I’m not particularly experienced with CFrame:Lerp. Would you have any idea how I could interpolate the AimPart (and as well as the rest of the model) to the Camera CFrame? My attempts are sending it either way far up and outwards or it’s rotating oddly around the Right Arm of the viewmodel. The problem is probably staring me in the face, but as I’ve said, I very rarely work with lerping, only normal CFrame and tweening.

1 Like

You should have some kind of a root part for reference which you will weld to the true character. You would then be able to easily find the offset for aiming down and hip. Play around with CFrames and their inverses, you can also check some 4x4 transformation matrix tutorials as that is what CFrames basically are, but sorted in a weird way.

1 Like

Should I have a Motor6D between the Head and Handle or a Motor6D between the Right Arm and Handle?

1 Like

I would suggest to the head so that players can do right handed reloading and such.

1 Like

As I said, a RootPart. Use a Motor6D to weld it to the head. Weld the arms and the weapon to the RootPart and handle it that way. The CFrame animations won’t have an effect on the keyframe animations, thus you can easily have multiple animations for different cases.

The only issue is that you will have to do some fine tuning as the handle might look like it is floating in the hand if the keyframes are not 100% in sync.

Also, make sure to use Motor6Ds for all welds that are joints. ManualWelds/Welds don’t handle CFrame changes efficiently.

2 Likes

Still a bit confused. But I think what you’re saying is logical. I’ve created something similar but the ADS system hasn’t been implemented yet. I’ll have to experiment a bit more with CFrames. Thanks for all your help!

1 Like