You mean someCFrame:toWorldSpace(otherCFrame)?
That’s the same as someCFrame * otherCFrame
If that’s not working, you need to do some debugging. Go to the console and mess around with CFrames and see where it gets you. Or make a script to visualize all the rotation components in a dummy system. That’s how I test CFrame math.
I saw your other post, I think you need to learn how CFrame rotation matrices work so you can get away from thinking in 90 degree 3-axis rotations. That’s not a good way to think about rotation and it can cause problems.
Edit: Actually that example you gave is not how rotation works anyways. That’s how rotating vectors works in linear algebra, but not rotations.
I tried multiplying the two CFrames but it ends up converging the two. And I did try debugging it and I really don’t know why it isn’t working. Using a vector kinda gives me what I want but because the math behind is made for vectors, it sometimes give invalid values which exceeds 180 degrees.
[ 1, 0, 0 ]
[ 0, 1, 0 ]
[ 1, 1, 0 ]
And, when you say
what do you mean exactly? I use 90 degrees as it is simpler for me to make examples with them.
I’m using vectors as it is the closest thing to what I’m trying to do and the way to visualize it. In my case, imagine the rotation is the UpVector of a part ( Y axis ( 0, 1, 0 ) ), now, let say I flip the part by 90 degrees on the X axis. After being flipped, the UpVector becomes ( 0, 0, 1 ) as it has been shifted.
What I’m trying to do is the same but with rotation.
Okay that first paragraph checks out but I’m still confused on the second paragraph.
You’re trying to treat rotations like vectors? I can’t imagine why, but I’ll suppress that for now. So you’re trying to rotate a vector of [0, 90, 0] around the X axis? [0, 90, 0] * [-1, 0, 0] = [0, 0, 90]
You’ll need to do vector multiplication to get this.
I removed the .LookVector as it created issues if not rotating it at 90 degrees. (CFrame.new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 0) * CFrame.Angles(math.rad(45), 0, 0))
Tough it still doesn’t work properly as it returns ( 0, 63, -63 ) when it should return ( 0, 45, 45 ).
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head.Neck
local NeckConnect = Neck.Part0
local Camera = workspace.CurrentCamera
local CurrentRotation = Camera.CFrame
if UserInputService.GyroscopeEnabled then
Camera.CameraType = "Scriptable"
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, function()
local Input, RotCFrame = UserInputService:GetDeviceRotation()
local X, Y, Z = RotCFrame:ToOrientation()
CurrentRotation = CFrame.fromEulerAnglesYXZ(X, Z, Y):ToWorldSpace(CFrame.Angles(math.rad(-90), 0, 0))
Camera.CFrame = CFrame.new(Head.Position) * CurrentRotation
Camera.Focus = CFrame.new(CurrentRotation * Vector3.new(0, 0, -10))
Neck.C0 = CFrame.new(Neck.C0.Position) * (CurrentRotation * NeckConnect.CFrame.Rotation:Inverse())
Character = NewCharacter
Head = Character:WaitForChild("Head")
Neck = Head.Neck
NeckConnect = Neck.Part0
It works perfectly but if the torso rotation isn’t 0 then it will start to desalign. And some of the modifications to the rotation are made due to IOS axises being swaped.