Help with approach to creating a proper FPS framework

Hello everyone and happy new year!

A couple of days ago creating a good FPS framework became one of my interests. Even though I am not at all a beginner in Roblox development and coding, making a framework is relatively new area for me.

Please notify me if you believe this is not appropriate category.

I would like to make a not too complicated framework including a gun model and a view model.
Having that in mind, I looked into different sources around the internet, and also a lot here on Roblox Dev Forum, but they all had different approaches.

I consider using EgoMoose’s open source FPS framework as a template, because I find it neat and rather relatively easy to understand. I also checked different sources on YouTube, but they mostly merge viewModel with the gun at the very start, which is generally not adviced. Such approach is acceptable, but has some weaknesses. I like EgoMoose’s approach, because that way gun contains three main parts, which determine the offsets and position of hands. There is a handle, which is sort of a RootPart of given gun, and also parts “Right” and “Left”, which determine hand placement. Gun iteself is attached and parented to character’s head, and the head to player’s camera. Working very well.

Chosen viewModel is actually a humanoid rig, with removed irrelevant parts, also attachments in relevant ones (only Motor6D’s left), disabled collision, anchored and transparent “Head”, and transparent UpperTorso, which is not anchored. HumanoidRootPart is removed.

The issue that I am trying to solve are viewModel animations, as well as character animations. If gun’s handle is attached (with Motor6D) to character’s head, it’s harder to achieve reloading effect and also other animations that come with such tool handling.

  • How would I animate such viewModel?

  • Should I take a different path? Left hand, for example, if constantly connected to “Left” part using Motor6D. What if animation included releasing left hand and moving it around, without touching the gun?

While asking these questions, I’m pretty sure I’ll have to use two separate animation for the same movement in the overall picture: viewModel animation for specific player’s view and character animation for other players.

I thank you very much for your replies in advance!

2 Likes

Ok, so why would it be more difficult to animate if gun is attached to hand? It doesnt affect anything right? Just means the gun moves with the animation. I don’t really see the issue here.

@Swiiiifty I made a typo. Gun is attached to Head, which is the only anchored part of the viewModel, which is at the same time attached to the camera (Head CFrame follows camera CFrame). Attaching is carried out using Motor6D, so it looks like this:

weapon.Parent = viewModel
viewModel.Parent = camera

local joint = Instance.new("Motor6D")
joint.C0 = CFrame.new(1, -1.5, -2)
joint.Part0 = viewModel.Head
joint.Part1 = weapon.Handle
joint.Parent = viewModel.Head

If the gun is merged with viewModel at the beginning (so you literally place hands on the gun manually), viewModel won’t change with player’s avatar.

One question comes with that:
would this be a good approach if you only had one rig type in game?

Yea I don’t see any problems with that if the rigs are either custom or are all the same.

You are right! There was no problem at all, only some of my inexperience at the time. After some changes in the script and welding, I figured you can freely animate hands and gun parts without the animation being interrupted by constantly self-correcting hand placement.


What I meant when mentioning gun and view model merging is that it means view model's type won't change with player's shape of arms (for example if view model is a Block Rig, but player is Rthro Rig). That's why I prefer separate view model creation.

Thank you @Swiiiifty , I guess it was only the matter of first try, some learning and a bit of a different approach than I was used to until now.