Would that also mean that in terms of rotation, a local rotation and a global rotation would exist?
ALRIGHT, I SOLVED THE PROBLEM!
So it turns out, I was doing EVERYTHING wrong for the rotation!
What I was using was math.asin(), as it seemed to work for the y axis, what I NEEDED however…
Was math.atan2(), as I needed to use both the X, and Z axis’s. And even though I didn’t understand what math.atan2() does, it makes it work perfectly now.
For reference, and to prevent everyone else from suffering, here’s the important part of the code:
runService.RenderStepped:Connect(function()
local reference = CFrame.new(0,0,0,1,0,0,0,1,0,0,0,1)
if running == true then
local look = CFrame.new(Vector3.new(char.HumanoidRootPart.Position.X,char.HumanoidRootPart.Position.Y,char.HumanoidRootPart.Position.Z) + char.HumanoidRootPart.CFrame:VectorToWorldSpace(Vector3.new(0,0,0)), char.RightHand.Position + char.HumanoidRootPart.CFrame:VectorToWorldSpace(Vector3.new(0,1,0)) )
local dist = (Vector3.new(0,char.HumanoidRootPart.Position.y - 1,0) - Vector3.new(0,char.RightHand.Position.y,0)).Magnitude
local tangant = math.atan2(look.LookVector.X,look.LookVector.Z) * 1
local tangant2 = math.atan2(char.HumanoidRootPart.CFrame.RightVector.X,char.HumanoidRootPart.CFrame.RightVector.Z) * 1
local theta = tangant - tangant2
motor6d.C1 = CFrame.new(0,0,dist) * CFrame.fromEulerAnglesXYZ(math.asin(-look.LookVector.Y) * 0.2,0,theta)
end
end)
I also took reference to this: How do i make the player's head move with the camera
Although, I probably would also like to ask what the hell math.atan2() does, as I found the initial explanation a bit confusing…
atan(y / x) = theta
-y/-x = y/x
-y/x = y/-x
atan2(y, x) handles this by taking y and x separately
Ah, I see.
I’ll try my best to keep this in mind in the future, thank you!