Offset Camera - Over-The-Shoulder And More For Mobile, Console, and PC

Download

OffsetCamera.rbxm (8.3 KB)

Github | LockedCamera

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:

image_2024-09-29_192658247

local OffsetCamera = require(script.OffsetCamera)

OffsetCamera.enable()

task.wait(40)

OffsetCamera.disable()
12 Likes

This looks wonderful! The UseSubjectRotation flag seems perfect for horror games chasing sequences ^^. I’ll give it a go for personal projects

Per usual sona created another banger and useful module, great job! :fire:

1 Like

Woah this was just the kinda thing I needed! Only complaint is how much the camera shakes when you walk, so just allowing the camera to not rotate would be nice
(Dont know if this was already implemented or not, I couldnt figure it out lol)

You can choose which subject to focus on and whether or not to include the subject’s rotation in the camera as settings listed prior :+1:

The default subjectName is the “RightShoulderAttachment”, but you can use the “Humanoid” or any other BasePart / Attachment / Humanoid under the Camera.CameraSubject.

You’ll also probably want to turn off UseSubjectRotation as the video demonstrates how wobbly that will make the camera.

1 Like

Hi! Tried testing an orientation offset on the camera and found a bug, when the orientation of the camera changes in the y axis, the character move direction changes along with it, which is a bit unfortunate. Are there plans to help this or is it intended behavior? Honestly the fact that the camera lets us add interpolated offsets this easily makes it a winner in my book already. This getting sorted out would make it just perfect.

Though I can maybe see someone maybe wanting this exact behavior? So maybe a flag named, idk `SubjectMovesInCameraDirection" that controls this might also be neat.

Code:

local offcam = require(workspace.Vendor.OffsetCamera)
offcam.settings.offsets = {
		[0.5] = CFrame.new(1, 1, 0) * CFrame.fromEulerAnglesYXZ(0, math.pi, math.pi / 24),
		[12.5] = CFrame.new(1, 2, 6),
}
offcam.enable()

https://gyazo.com/ed2bc9f3e79b2e3f509a38a1cae0a461

Originally this was intended behavior and not a bug, but I can see the use case. I’ll look into making it a flag, as well as adding support for sitting / being grounded.

1 Like

I noticed that after the character dies, the camera wont follow the players character any more. Might be something to look into.

Also uh any solution to this property?

Well that’s an issue. I’ll get to fixing this as soon as I can. In the meantime, if the humanoid dies while enabled, you can wait for it to respawn and manually set the Camera.CameraSubject to the new Humanoid

2 Likes

Thank you, was having the same issue!

wait, dunno if you mentioned it but is there a way to stop the camera from rotating when you zoom in?

This is defined by the offsets. You can see in the offsets table that there is a CFrame at 0.5 distance with a Z rotation. This is changeable from the settings or in your local copy.

1 Like