How do I replicate Real Arm movements to Fake Arms (ViewModel)?

What problem are you having? I’m not quite sure which CFrame to share.

The arm offset problem in post 50.

The one in posts 50 is not a Viewmodel!
That’s from:

1 Like

Alright, my apologies but what did you end up doing to solve this problem?

The problem was animation not playing due to the Motor6Ds name and character’s Motor name not being the same, what problem are you countering right now?

Well, this is the problem that I am encountering is that the arms are not moving the way I need them to unlike your video, I also couldn’t really tell your solution to that problem, because I much rather do it your way, due to the way you setup the guns. But this is what I tried:

game:GetService("RunService").RenderStepped:Connect(function()
char.Torso["Right Shoulder"].C0 = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((mouse.Origin.p - mouse.Hit.p).unit.y),1.55,0)
char.Torso["Left Shoulder"].C0 = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((mouse.Origin.p - mouse.Hit.p).unit.y),-1.55,0)

end)

But this is the problem I run into,

https://gyazo.com/77f663cfaa20fb4ad51a838e66f4cebb

As you can tell, the gun and the arms do not stay at a set height.

If you know any solutions please let me know.

Did you even apply a ViewModel? This is just the arms following the mouse position, not a ViewModel?

1 Like

Very much appericated i advise him to recap over EgoMoose’s Viewmodel example very helpful,make sure if do that,replicate it to the client also which is included in his post

This is why i switched to Unity i can make a viewmodel so much better and easier

Hello, im trying to make something similar, so i tried to apply the @Hexcede idea on post 43.
I also switched “char.Torso[“Right Shoulder”].Part0.CFrame * camera.CFrame:Inverse()” with “camera.CFrame * char.Torso[“Right Shoulder”].Part0.CFrame:Inverse()” as it shows on post 49, but it’s still very far from working, and i dont have any idea to fix it. :neutral_face: :thinking:

This is how it works:

Code:

runService.Stepped:Connect(function()
    local cameraOffset = camera.CFrame * char.Torso["Right Shoulder"].Part0.CFrame:Inverse()
    local offset = char.Torso["Right Shoulder"].C0 * char.Torso["Right Shoulder"].C1:Inverse()
    local newLocation = camera.CFrame * cameraOffset * offset
    local oldLocation = char.Torso["Right Shoulder"].Part0.CFrame * offset
    char.Torso["Right Shoulder"].Transform = char.Torso["Right Shoulder"].Transform * oldLocation:Inverse() * newLocation
end)

Any help is welcome! :slightly_smiling_face:

1 Like

@Headstackk If I’m not mistaken, in order to solve the problem of moving the tool into the view model’s hands, you ended up renaming the torso of the view model to Torso? When I did that, it worked as expected, but the first person collision issue from the solution post happened again. Can you explain how you resolved that?

You can set the view model to a separate collision group

I’m not sure that’s the issue, since I already have the view model and tool set to cancollide false. I’m guessing that it has something to do with the fact that two humanoids are on top of each other, but I’ve seen it in other games.

When I set the viewmodel collision group to its own category i resolved the glitching for me

I’ll try it, but it says on the roblox developer website that when cancollide is set to false, the part will not collide with anything under any circumstances.

Edit: nvm, it did work, tysm for your help!

1 Like

So, i tried making a viewmodel script from the code snippets and the repro file that colbert2677 gave and made my own modifications to it, but it doesn’t work correctly, and the topic has no further information on the script after Hexcede’s conclusion on the viewmodel problem.

local LocalPlayer = game:GetService("Players").LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local RenderStepped = game:GetService("RunService").RenderStepped
local ViewModel = game:GetService("ReplicatedStorage").ViewModel:Clone()
local ViewModelRoot = ViewModel.PrimaryPart
local ViewModelTorso = ViewModel.Torso

ViewModel.Parent = workspace

RenderStepped:Connect(function ()
	ViewModelRoot.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0, -1.5, 0)
	-- Hardcoded logic test
	ViewModelTorso["Left Shoulder"].Transform = Character.Torso["Left Shoulder"].Transform
	ViewModelTorso["Right Shoulder"].Transform = Character.Torso["Right Shoulder"].Transform
	ViewModelRoot["RootJoint"].Transform = Character.HumanoidRootPart["RootJoint"].Transform
if Character:FindFirstChildOfClass("Tool")~= nil then
	Character.Torso.ToolGrip.Part1 = nil
	ViewModelTorso.ToolGrip.Part1 = Character:FindFirstChildOfClass("Tool").BodyAttach
	ViewModelTorso.ToolGrip.C0 = ViewModelTorso.ToolGrip.C0 * CFrame.new(0,0,0)
end
end)

my viewmodel also uses HumanoidRootPart instead of Torso, as the animations i use contain torso rotations.
image

2 Likes

Make sure you have the viemodel in a seperate collision group, if that doesnt work then I can show you my version of it!

the collision i’m having in the video is actually the tool itself rather than the viewmodel.
I’m having difficulties changing the motor6D’s to the viewmodel, but you could show me your version, too, if that’s okay.

The only problem is when you equip a tool and look upwards, the tool doesnt move with the arms.

So you’re saying that it works when the viewmodel primary part is the Torso?
Becouse by me the tool dosn’t move a single stud.

1 Like

Alright, I know I’m very late. BUT. I found a resource that uses the real arms like viewmodels. Just putting this out here so that other people don’t have to go thru this pain.

[Only for R6 though]

2 Likes