I have 2 CFrames: one for the arm of a player, and one of the camera. I want to rotate the arm sorta parallel to the X rotational axis of the camera (the looking-up-and-down axis). I do not want it to match the camera CFrame/Orientation, but I want to offset it’s current CFrame by this camera-x-axis rotation. How would I do this?
It depends on whether you have an r6 or r15 rig, but the main concept is that you would translate your camera world CFrame into something relative to the player and then with that relative CFrame we are able to get the angle that we can use to put on our shoulder joint. It could look something like this. You would also have this in a loop so it updates every interval
local rootPart = character.HumanoidRootPart
local camera = workspace.CurrentCamera
local relative = rootPart.CFrame:ToObjectSpace(camera.CFrame)
local degree = math.asin(relative.LookVector.Y)
ShoulderJoint.C0 = CFrame.Angles(degree, 0, 0)
There is always some offset that the joint has automatically so I did not account for that if you can give me the rig you are using I can give you a script you can use
Here is what I have (I am using an R15 rig):
local newConnection = RunService.Stepped:Connect(function()
leftShoulder.Transform = CFrame.Angles(LightAttack.CurrentLookAngle, 0, 0 ) * leftShoulder.Transform.Rotation + leftShoulder.Transform.Position
rightShoulder.Transform = CFrame.Angles(LightAttack.CurrentLookAngle, 0, 0 ) * rightShoulder.Transform.Rotation + rightShoulder.Transform.Position
end)
This codes offsets the arms properly but it doesn’t angle it properly. You can see it sorta works but doesn’t take account for the Upper and Lower torso angles:
(this sorta works because I don’t move the torso much)
(this doesn’t work because the animation I’m playing affects the torso, look at what happens when I look straight down)