So I understand that you can get a CFrames full rotation by doing this
But In my case, I just want one of the axis. This is what I’m struggling with. I’m not sure how to construct that
So I understand that you can get a CFrames full rotation by doing this
But In my case, I just want one of the axis. This is what I’m struggling with. I’m not sure how to construct that
local Rotation = CFrame.new().Rotation
Rotation.Y -- Y axis
So in my case I am trying to get the rotation of the camera, and I tried this and it returning 0
Also aswell I tried putting the X Y Z rotation in a CFrame.Angles
and it didnt work at all
I have a feeling im supposed to use this, but im not sure what the arguments correlate too
I think i may be on the right track but im not sure
CFrame.new(0,0,0,camera.CFrame.XVector.X,camera.CFrame.XVector.Y,camera.CFrame.XVector.Z,camera.CFrame.YVector.X, camera.CFrame.YVector.Y, camera.CFrame.YVector.Z, camera.CFrame.ZVector.X, camera.CFrame.ZVector.Y, camera.CFrame.ZVector.Z)
The arguments are part of the CFrame matrix, they have a part in Rotation.
To get the components, this will also give you these “R” values:
local Components. = {workspace.CurrentCamera.CFrame:GetComponents()}
So for example how would i construct a new cframe rotation with just the Z rotation with that infromation
But like how would i construct that in code
local x, y, z = camera.CFrame:ToOrientation()
Though they will be in radians. If you want them in degrees you can use math.deg(y).
I tried this but its saying the ToOrientation expects a CFrame
Use a Colon instead of a period.
Oh my mistake, yeah its not working its pretty wonky actually
I tested it with setting it directly to the rotation and then htis method and they are different, its def not rotating correctly
How are you setting the CFrame?
I am multiplying it by a blank position cframe
I just tried the GetComponents method and that just flings me into the far lands…
and it doesnt make any sense im setting each argument to its corresponding correct thing
Here is a little example I made were Part1 copies the orientation of Part2.
local RunService = game:GetService("RunService")
local p1 = workspace:WaitForChild("Part1")
local p2 = workspace:WaitForChild("Part2")
RunService.Heartbeat:Connect(function()
local x, y, z = p2.CFrame:ToOrientation()
p1.CFrame = CFrame.new(p1.Position) * CFrame.Angles(0, y, 0)
end)
Try to only set the rotation values, not the position ones.
I’m not sure if this works, but this is a tedious method:
while task.wait() do
local Components = {workspace.CurrentCamera.CFrame:GetComponents()}
local PartComponents = {workspace.Part.CFrame:GetComponents()}
workspace.Part.CFrame = CFrame.new(0,0,0,PartComponents[4],PartComponents[5],PartComponents[6],PartComponents[7],PartComponents[8],PartComponents[9],Components[10],Components[11],Components[12])
end