Tried making character look where the camera is looking, and got stuck

So the short and sweet of it it that there is a Motor6D connecting LowerTorso and UpperTorso. Motor6D has a target CFrame and i just ask the client what his camera’s LookVector is and apply it to the target CFrame of the Motor6D. WELL COOL, works.

Now to the problem.
When i turn, the Motor6D makes the rotation relative to the LowerTorso.

See that the UpperTorso doesn’t follow the camera correctly.
So things i tried:

  1. Making TargetAngle face where the HumanoidRootPart's LookVector is and from that i added the camera’s LookVector. (might be the solution i just did it poorly :laughing:)

  2. Making the Motor6D… not a Motor6D (just made the character loose his legs)

The code with the problem:

local waist = script.Parent:WaitForChild("UpperTorso"):WaitForChild("Waist")
local ans = script.Parent.CamAns

function answears(plr,look) --the problem is here
	waist.C0 = CFrame.new(waist.C0.p, Vector3.new(math.floor(look.X* 100)/100,math.floor(look.Y * 100)/100,math.floor(look.Z * 100)/100))
end

ans.OnServerEvent:Connect(answears)

The code requires more things so here it is.
Turn.rbxl (18.9 KB)
Any help appreciated. Sorry for broken english :grinning:.

I solved it by myself.
(30char)

For people who had the same problem (like me) and was visiting this topic with no answers, did you obtain a rotation offset similar to this other topic?

where a rotation offset was found?

local rootCFrame = HumanoidRootPart.CFrame;
local rotationOffset = (rootCFrame - rootCFrame.p):inverse();

Just a heads up, you should provide the solution to your problem even if you solved it yourself. There will be a lot of people that have had the same problem as you, and will visit this post. The solution would help a lot.

4 Likes