To my knowledge, if CFrame was like 2, 2, 0, Inverse would be -2, -2, 0
But with my example, CFrame is (rounded) 1, 6, 0 but the inverse is returning 0, -1, -6??
local Inverse = Camera.CFrame:Inverse()
21:46:13.387 CAM 0.99890559911728, 6.0043773651123, 0
21:46:13.387 INV 0, -0.99890559911728, -6.0043773651123
This should not be happening. Try printing something simple in the command line. For example:
print(CFrame.new(-2,-5,7):Inverse().Position). It should return
2, 5, -7. If it doesn’t then you most likely have a bug or some other error on your hands.
I tried this
local C = CFrame.new(2, 2, 0)
local I = C:Inverse()
and it worked as intended. But there should be no reason why mine isn’t working. There’s literally no code between the inverse and the prints
Strange. Maybe try doing this and seeing if it works? I doubt it will, but you can try it.
local camFrame = Camera.CFrame
print("CAM: ", camFrame.Position)
print("INV: ", camFrame:Inverse().Position)
The key here is that the C, CFrame has no rotation.
If you were to rotate it let’s say 90 degrees.
local C = CFrame.new(2, 2, 0)*CFrame.Angles(0,math.deg(90),0)
local I = C:Inverse()
It’s going to be a lot different:
22:17:35.547 2, 2, 0 - Edit
22:17:35.547 0.59910517930984, -2, 1.9081596136093 - Edit
I don’t rotate the camera at all?
I do have a tween that plays, and my prints are being printed in a while loop, so it constantly gets up to date info. But this shouldn’t cause any differences in the inverse
local CameraInTween = TweenService:Create(
CFrame = Camera.CFrame - Vector3.new(-1, 4, 0)
Waiiitt a minute… if you are using the positions then can’t you just do
No, I just printed the .Position, cause I didn’t really want the print to be filled with a bunch of extra numbers.
Alright, I just searched and found this answer:
Well CFrames are actually 4X4 matrices.
Inverse of a CFrame is another CFrame which when multiplied (matrix multiplication) with the original CFrame gives identity CFrame (ie CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) or simply CFrame.new())
if ‘a’ is a CFrame, then
a * a:inverse() = CFrame.new()
If you want to know how to multiply matrices here is an example:-
(I used 2x2 matrix because I think it is the easiest to understand…)
For more inform…
You might have to have some knowledge of matrices to understand everything this is saying. If you don’t understand matrices you can try learning about them
Because CFrames are really just inverses, I’m guessing that that the inverse is the same as the
Inverse of a Matrix.
Honestly, I completely forgot that CFrames were matrices. That’s my bad. You can try checking out the resources below.
#CFrames are how ROBLOX represents the 3D position and orientation of objects in the game world.
Understanding how these work can lead to easier to write, easier to read, and overall more efficient CFrame code.
If you’ve ever done something like:
you know that it gives you 12 numbers. What do these numbers mean?
Well before we start, let’s think about CFrame.lookVector. lookVector is a unit vector (vector with a magnitude of 1) that points in the direction the CFrame is f…
It might take you awhile to understand if this is all new to you. Instead, can you tell me what exactly you are trying to accomplish by using the inverse?