So it seems I’m having some trouble understanding what exactly CFrame.fromAxisAngle() does. My original understanding was that fromAxisAngle() would accept a vector and an angle. The vector (illustrated in blue) would be the direction in which the CFrame would point, and the given angle (illustrated in red) would determine the rotation around said axis.
But ive found that this doesnt seem to be the case. Here’s an example:
I have this function here called update(), which accepts an angle (radians) and rotates a part to have that given angle.
local function update(deg)
The function then gets the tangent of that angle so that it may attempt to produce a unit vector to give to the fromAxisAngle() constructor:
local TangentAngle = math.tan(deg)
local Vector = Vector3.new(0, TangentAngle, 1).Unit
Now lastly, I give the vector to the constructor and apply the newly created CFrame to the object:
local Axis = CFrame.fromAxisAngle(Vector, 0) --angle is omitted for now, should not affect anything anyways
Motor.C0 = Axis + Motor.C0.Position
to sum up the whole function:
local function update(deg)
local TangentAngle = math.tan(deg)
local Vector = Vector3.new(0, TangentAngle, 1).Unit
local Axis = CFrame.fromAxisAngle(Vector, 0)
Motor.C0 = Axis + Motor.C0.Position
end
But this doesnt end up moving the part at all!
I attempted to make my own function of the expected behavior, to see if my code had any issues:
local function AxisAngle(Axis, angle)
local frame = CFrame.lookAt(Vector3.new(), Axis)
return frame
end
When this function was used in place of the fromAxisAngle() constructor, the part began moving exactly as expected.
Am I misunderstanding how the constructor works, or was there an error in my code? any help would be appreciated.