How can i setup a viewmodel campart rig?

Idk how to explain this
Im trying to make a gun system that has a viewmodel

the viewmodel has a part called CamPart

the viewmodel mirrors the characters movements so i cant play the animation alone on the viewmodel

The rig used to animate a gun is a r6 character with the campart rigged and named the same from the viewmodel

Im trying to copy the camparts rotations onto the players camera

but since theres no CamPart on the character ingame, theres nothing to copy over

whats the best way to get past this? Put a CamPart in the character and get the cframes from that? Or is there a way to get parts moving from an animationTrack?

I would simply just update the cameras CFrame every frame before the rendering phase.

local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local camPart = -- path to the camera part

runService.PreRender:Connect(function()
     camera.CFrame = camPart.CFrame
end)

But also i want to mention, your way of making a viewmodel, judging from your explanation is pretty messy and could perform worse than just making the viewmodel be a child of workspace.CurrentCamera, and updating its CFrame every frame to be on the camera. But it could be im just misunderstanding something in your explanation.

1 Like

Hi thanks for responding; ive explained it badly


basically, theres a part called campart in the viewmodel
I rigged a r6 character with the CamPart copied over from the viewmodel

problem im having right now is when i play the animation on my character, there is no campart in my character


So theres no campart moving

Im trying to figure out how to get the cframes from the campart in the animation; idk if theres a method to get the movement from animationtracks or if i should try putting a CamPart into the character when spawning in, so the animation moves the CamPart and i can copy the cframes from that.

Well, i can see the actual viewmodel is under the camera, so thats good, and means you can reference it in the script i gave you using:

local camPart = camera:WaitForChild("ViewModel"):WaitForChild("CamPart")

All thats left now, is animating the viewmodel itself so the CamPart moves how you want it to.
You can do this using Animator and Animation.

1 Like