Download
OffsetCamera.rbxm (8.3 KB)
What does this do?
Flexibility
Offset Camera is used to offset the camera from its focus which is desirable for Vehicle cameras, Over-The-Shoulder cameras, and some First-Person cameras. It was designed with gun systems in mind, but made to support a variety of use-cases on all platforms and avatar types. As later discussed it has many concise settings to be as flexible as possible.
Native Support
Offset Camera is a custom camera implemented using Roblox’s own CameraInput
, ZoomController
, PopperCam
, and TransparencyController
modules found under the CameraModule
to capture the native feel of the Roblox Classic Camera and maintain seamless support & sensitivity across Mobile, Console, and PC for R6 and R15 avatars and more!
Settings
Offset Camera has many individual settings one would expect:
OffsetCamera.settings = {
subjectName = "RightShoulderAttachment" :: string?,
offsets = {
[0.5] = CFrame.new(1, 1, 0) * CFrame.fromEulerAnglesYXZ(0, 0, math.pi / 24),
[12.5] = CFrame.new(1, 2, 6),
},
maxPitch = math.rad(65),
minPitch = math.rad(-75),
useSubjectRotation = false,
mirrorOffsets = false,
rotateHipsToFollowCamera = true,
}
Subject Name
A string representing the name of an Attachment
, BasePart
, or Humanoid
found under the Camera.CameraSubject
(or its parent, the Character
, if its a Humanoid
), which is used to compute the Focus
of the camera.
If the field is nil
or a descendant with the name can’t be found, it will use the Camera.CameraSubject
itself to compute the Focus
.
Setting the Camera.CameraSubject
should work as expected otherwise.
Offsets
A table of [Distance]: Pivot
pairs which are linearly interpolated between by the Zoom Distance.
If there are no entries in the table, it will use the CFrame.identity
as an offset from the camera subject.
If the Zoom is less than the minimum pivot’s distance or more than the maximum pivot’s distance, it will clamp to using that pivot.
Max & Min Pitch
How far up and how far down in radians you are allowed to rotate your camera respectively.
Use Subject Rotation
A flag to include the subject’s intrinsic rotation instead of just the raw Pitch and Yaw of the camera. When true
the camera will typically bounce around with the subject.
Mirror Offsets
A flag to flip all offsets into their respective “Mirrored” counterparts, by negating the X
position and negating the Y
and Z
angles of each offset. This is intended for games that wish to support Left Handed gameplay but are primarily Right Handed, or vice-versa.
This will not change the subjectName
setting, meaning if you are tracking the RightShoulderAttachment
then this will not change the subjectName
to the LeftShoulderAttachment
.
Rotate Hips To Follow Camera
A flag to toggle the built-in hip rotation that is replicated to all other clients using Unreliable Remote Events. Works for R6 by rotating the Torso and each Leg respectively, and works for R15 by rotating the UpperTorso.
If the Camera.CameraSubject
is not a Humanoid
then this will not apply.
Implementation
OffsetCamera.enabled = false
function OffsetCamera.enable()
function OffsetCamera.disable()
To use Offset Camera simply parent it to somewhere the client can access, require the module, and call the OffsetCamera.enable()
method. Here was my setup when recording these demos using the Client
RunContext
:
local OffsetCamera = require(script.OffsetCamera)
OffsetCamera.enable()
task.wait(40)
OffsetCamera.disable()