Help with arms following the camera up and down

  1. What do you want to achieve? Keep it simple and clear!

I want my arms to track the camera up and down like in fps games.

  1. What is the issue? Include screenshots / videos if possible!

It’s behaving in a weird way. Here’s a video :

robloxapp-20231105-1529096.wmv (3.7 MB)

Very confusing stuff.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried talking to the assistant, but it didn’t give me the info I wanted. I don’t know much about Euler’s angle, so that doesn’t help.

This is my local script (where it happens)

local ps = game:GetService("Players")
local run = game:GetService("RunService")

local player = ps.LocalPlayer
local char = player.Character
local cam = workspace.CurrentCamera

local viewmodelFolder = char:WaitForChild("Viewmodel") --this is created on playerJoined in a server script, works fine
local viewmodelRightArm = viewmodelFolder:WaitForChild("ViewmodelRightArm")
local viewmodelLeftArm = viewmodelFolder:WaitForChild("ViewmodelLeftArm")
local viewmodelCam = viewmodelFolder:WaitForChild("ViewmodelCam")

--variables

--functions

local function renderFunction(deltaTime)

	deltaTime = deltaTime

	viewmodelLeftArm.LocalTransparencyModifier = 0
	viewmodelRightArm.LocalTransparencyModifier = 0

	local rz, ry, rx = cam.CFrame:ToEulerAnglesXYZ()
	--rz = up and down, rx = left and right

	print(math.round(math.deg(rz)))
	viewmodelCam:WaitForChild("ToHead").C1 = CFrame.Angles(math.sin(rz) * -1, 0, 0)
end

--methods
run:BindToRenderStep("renderFunction", Enum.RenderPriority.Last.Value + 1, renderFunction)

I tried many ways for the last week and none of them work as intended. Help would be nice, thanks.

1 Like

Update

I have the solution, I just had to watch a tutorial (I should have done this a long time ago!)

If someone has the same problem, I used the SetPrimaryPartCFrame() to the CFrame of the camera each render. It might not be good for performance, but it does the job.

I also changed it so that it moves smoothly! It uses the Lerp function of the camera’s (cam) CFrame. It is also modifiable with the “VIEWMODEL_SMOOTHNESS” constant in variables.

Source : https://youtu.be/c96NS9dxP60?t=1007

I hope this helped someone.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.