Introduction
I’m trying to experiment with the default Roblox camera system, trying to see how it works. I’ve had a look at the source and there’s one thing I do not understand.
Main Question
- What’s the relationship between a mouse movement and the corresponding mouse movement? If I move my mouse left 10 pixels, what’s the equivalent camera pitch and yaw movement?
There’s not a particular reason I’m looking into this, just curious.
Aside
I narrowed down the function responsible for this:
function BaseCamera:CalculateNewLookCFrameFromArg(suppliedLookVector: Vector3?, rotateInput: Vector2): CFrame
local currLookVector: Vector3 = suppliedLookVector or self:GetCameraLookVector()
local currPitchAngle = math.asin(currLookVector.Y)
local yTheta = math.clamp(rotateInput.Y, -MAX_Y + currPitchAngle, -MIN_Y + currPitchAngle)
local constrainedRotateInput = Vector2.new(rotateInput.X, yTheta)
local startCFrame = CFrame.new(ZERO_VECTOR3, currLookVector)
local newLookCFrame = CFrame.Angles(0, -constrainedRotateInput.X, 0) * startCFrame * CFrame.Angles(-constrainedRotateInput.Y,0,0)
return newLookCFrame
end
- How does it work?
- What if I wanted the mouse movement that correlated to a certain look vector (the function backwards)?
- Expanding onto this, for example, what is the needed pixel movement to have a look vector of
(1, 0, 0)?
- Expanding onto this, for example, what is the needed pixel movement to have a look vector of
sorry if I explained badly, let me know if you need me to clarify