This isn’t a tutorial on how to implement a ViewModel, it’s more like a topic that can help you design your FPS game better.
Starting with poses
If you played Arsenal or Phantom Forces you may have noticed the difference in their ViewModels, that being the way they are animated.
-
Arsenal’s ViewModels use Roblox animations (probably animated in Blender), but what’s interesting here is that the developers posed the arms in an “Idle” state so that the animation can fully load without the arms looking like this:
-
Phantom Forces’ ViewModels use CFrames, so that’s why the animations look a bit unrealistic, but more “bounced”. “CFrames” don’t load, they are just positions in space,
:lerp()
ed if I remember correctly (from an uncopylocked place). I am not sure how they initially posed the arms but I believe the same way as Arsenal, "Idle"d style.
Continuing with Z-Fighting
No, not images. I am talking about parts phasing through each other:
From my perspective, there are only 4 ways to fix this:
1. The big and widely-used BasePart.AlwaysOnTop (not an existing property):
This is what many FPS games use if not all of them. This basically works by “drawing” the chosen parts on top of all other objects, something like having 2 Cameras at once.
2. Highlights
Highlights are basically the same model but AlwaysOnTop (not necessarily) and with an Outline/Fill Color/Transparency. These could “render” the ViewModel on top, although the downside is no shadows or materials:
And with this code, we can automate the process
for i,v in pairs(workspace["viewmodel arms"]:GetDescendants()) do
if v:IsA("BasePart") then
local h = Instance.new("Highlight")
h.Adornee = v
h.FillTransparency = 0
h.FillColor = v.Color
h.OutlineColor = v.Color
h.Parent = v
end
end
3. ViewportFrames
This method is efficient for drawing the VM (ViewModel) on top of other parts, although its lighting is broken and has a lack of Workspace stuff (such as ForceField material animation, which can be “hacked” easily):
4. SurfaceGuis
This is a really bad method of “Highlights”, which can render on top of other objects, but is performance-intensive and doesn’t have automatic curves (it’s either square or rectangle):
On this “hacky” method, I’m going to do a tutorial on it soon and probably update this topic once it’s finished. It may not be performant, but works.
Your best option until Roblox adds BasePart.AlwaysOnTop is using the current way of rendering a VM on Roblox: Animations (with poses, Arsenal-like) and positioning by the Camera, meanwhile clipping through parts.