You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make the player’s body move with the camera -
What is the issue? Include screenshots / videos if possible!
The head moves the wrong direction when you turn your body -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I couldn’t find anything about this, i tried:
- removing the math.asin
- subtracting the humanoid rootparts cframe’s X lookvector from the one of the camera (which works except that when you move your head 90 degrees in any direction (from the world rotation) it starts going back which it should but only from the rootpart’s rotation)
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is what i have so far:
local plr = game.Players.LocalPlayer
local neckC0 = CFrame.new(0, 0.8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local function onUpdate(dt)
if plr.Character ~= nil then
local camera = workspace.CurrentCamera;
local body = plr.Character.HumanoidRootPart
if plr.Character.Head.Neck ~= nil then --neck joint is not broken
if plr.Character.UpperTorso:FindFirstChild("Waist") ~= nil then
local neck = plr.Character.Head.Neck;
local waist = plr.Character.UpperTorso.Waist;
local theta = math.asin(camera.CFrame.LookVector.y)
local theta2 = math.asin(camera.CFrame.LookVector.x-body.CFrame.LookVector.X)
neck.C0 = neckC0 * CFrame.Angles(theta*0.5, -theta2, 0);
CFrame.new()
waist.C0 = waistC0 * CFrame.Angles(theta*0.5, 0, 0);
end
end
end
end
game:GetService("RunService").RenderStepped:Connect(onUpdate);
Here is a video showing what it does now
Reddit post with the video because i can’t upload it to here
(don’t mind my character nor the video quality)