-
What do you want to achieve? I would like to achieve making the players upper body (upper torso, arms, and head) follow their mouse while in first person.
-
What is the issue? The problem is that right now the upper body only follows the mouse when rotating sideways. I would like to have it follow the mouse when moved up and down as well.
-
What solutions have you tried so far? So far I have looked up tutorials on YouTube and the DevForum but was unable to find anything that helped much.
I know that many games have this system built in, so I know it must be possible, I just haven’t found any information on how to actually do it.
Please help if you can. Thank you.
Here’s how I might do it:
local lowerTorso = char.LowerTorso.Waist --//Path to the Motor6D you want to rotate
local camera = workspace.CurrentCamera
local base_CF = lowerTorso.C0 --//Cache initial CFrame for the Motor6D
local MAX_ANGLE = 45 --//Maximum rotation applied to the joint
local function lookAtCamera()
--//Compare camera's look direction to a base direction to get a scalar (or value we can use to multiply the maximum angle)
local diff = camera.CFrame.LookVector:Dot(Vector3.new(0, 1, 0))
local angle = MAX_ANGLE * diff
lowerTorso.C0 = base_CF * CFrame.Angles(0, math.rad(angle), 0)
end
game:GetService("RunService").RenderStepped:Connect(lookAtCamera)
Thanks. Will go try this out now.
Just tried this out. I am running into an error that says CFrame is not a member of the motor6D
My bad, I edited my original post.
No errors this time. It just doesn’t work - script is in startercharacterscripts - maybe that’s the problem?
Should be a LocalScript, StarterCharacterScripts should be fine.
It’s also not standalone, you might need to change like which joint to rotate as well.