Hello, I am trying to make a first person camera effect but the methods I’ve tried ended up looking janky. So I concluded that since the point the camera revolves around and zooms into is typically the head of the character, I could make the arms rotate around the head to give off a convincing first person camera effect.
The arms facing relatively to the mouse y of the player’s screen works pretty flawlessly but there’s a problem when you go into First Person mode.
The arms look like they move backwards in the opposite direction to the camera’s LookVector the more you look up, this is because the motor6Ds are rotating around their own unique pivot point as opposed to the camera’s position (which would solve the problem)
Here is my code:
Code
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Char = script.Parent
local Torso = Char:FindFirstChild("Torso")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LerpSpeed = 0.2
local rc0,lc0
RunService.Heartbeat:Connect(function()
Char["Right Arm"].LocalTransparencyModifier = 0
Char["Left Arm"].LocalTransparencyModifier = 0
local rightX, rightY, rightZ = Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
local leftX, leftY, leftZ = Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()
rc0 = (Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y))
Torso["Right Shoulder"].C0 = Torso["Right Shoulder"].C0:Lerp(rc0, LerpSpeed)
lc0 = (Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-Mouse.Hit.p - -Mouse.Origin.p).unit.y))
Torso["Left Shoulder"].C0 = Torso["Left Shoulder"].C0:Lerp(lc0, LerpSpeed)
end)
Here’s another diagram if you need more explanation:
I need help with this because I don’t really know trigonometry or how to make a Motor6D revolve around a pivot point (being the character’s head in this case)
Thanks again!