The title says it all. What is that? How can I use it for an object rotation. I really have no idea. An example please?
Check out the documentation on this:
vX, vY, and vZ are the directional vectors.
In the CFrame.new() constructor there’s an argument for ‘lookAt’ of where the front surface should face.
This use of CFrame.new() was deprecated for CFrame.fromMatrix() which instead takes 3 vectors of rotation: lookVector, rightVector and upVector.
The documentation gives an example of this useful function.
Is that correct or have I still not understood it???
CFrame.fromMatrix(Vector3 pos,Vector3 vX,Vector3 vY [,Vector3 vZ])
Default for vZ is
It constructs the CFrame in a similar way to CFrame.new with 12 arguments.
CFrame.fromMatrix( Vector3.new(x,y,z), Vector3.new(r00,r10,r20), Vector3.new(r01,r11,r21), Vector3.new(r02,r12,r22) )
is the same as
CFrame.new( x,y,z, r00,r01,r02, r10,r11,r21, r20,r21,r22 )
In fromMatrix, vX represents rightVector, but in the CFrame.new method it is the 4th, 7th, and 10th arguments. (similar things with upVector and lookVector)
CFrame.fromMatrix is not a combination of CFrame.new and CFrame.Angles (you can still get the same result), it exists for an entirely different reason. (probably for something like the example on the wiki, so the CFrame.new with 12 arguments doesn’t have to be used)
Could you set another example because:
I don’t know now who is telling the truth and who is not telling it. But if you make the CFrame.new(Vector3.new(1,2,3))*CFrame.Angles(math.rad(90), math.rad(90), math.rad(90)) you get the same as CFrame.fromMatrix(Vector3.new(1,2,3), math.rad(90), math.rad(90), math.rad(90))?
Nope the three arguments are actually unit vectors (like LookVector). LookVector would be vZ, UpVector would be vY, and RightVector would be vX. That means you can do some really weird stuff with conflicting directions, e.g. turning stuff inside out. CFrames represent rotations with these vectors which is why I said its a combination. When you do CFrame.Angles a CFrame is created with its position as all zeros, and three directions (one for each axis).
The reason CFrames can have three directions like this is because mathematically three vectors are used so why not let them be anything.
local Part = istance.new("Part", workspace) Part.CFrame = CFrame.fromMatrix(Vector3.new(0,10,0), 0,90,0)
This will make a new Part 10 Studs in Y-Axis and turn it 90 deg in Y-Axis?
It needs Vectors instead of numbers.
Ok, but the part was created with 10 Studs in the Y-Axis or?
Is that better???:
Part.CFrame = CFrame.fromMatrix(Vector3.new(0,10,0), Vector3.new(1,0,0), Vector3.new(0,1,0), Vector3.new(0,0,1))
Yep that’s correct! That will make it face in the Z direction with its top facing the Y direction and the right face in the X direction.