How can I offset the camera's focus so that the character is kept permanently to one side

I’m trying to make a UI that partially covers the client’s screen, but keeps their character visible by pushing the character to the side like so:



I want the character to stay in that location on screen, even as they move around or rotate the camera

I’ve been snooping around for solutions for a while but haven’t gotten to anything.

  • Humanoid.CameraOffset does not work because the offset is relative to the character’s lookvector
  • I found this module from this thread that looks like it’s exactly the same thing I am trying to achieve except the code just doesn’t work for me. The sizing and positioning is wonky and doesn’t match the frame
  • This thread is similar but doesn’t allow the camera to movie

I got these screenshots using this code, which is almost the solution but depending on the camera’s rotation its position keeps jumping, and I have no idea why

RunService:BindToRenderStep("ViewportResizer", Enum.RenderPriority.Camera.Value + 1, function()
	Camera.CFrame = Camera.CFrame * CFrame.new(
		0, 0, 0,

		1, 0, 0,
		0, 1, 0,
		-.75, -.1, 1
	)
end)

I’m not good with cameras or complex math. Could anyone help?

Hello.

Try this code:

RunService:BindToRenderStep("ViewportResizer", Enum.RenderPriority.Camera.Value + 1, function()
	Camera.CFrame *= CFrame.new(-5, 0, 0)
end)

i cant believe its that simple thansk so much

1 Like

No problem, glad it helped.

Just for clarification and so that you can use this in the future:

Whenever you have any CFrame, you can offset it just by multiplying it by a new CFrame.
The parameters you can use are the following:

YourCFrame * CFrame.new(RightVector, UpVector, ForwardVector)

All of these are RELATIVE to YourCFrame. This means that if you do this:

YourCFrame *= CFrame.new(5, 0, 0)

It will move YourCFrame to ITS right. If you want to move it to the left, you just do -5, of course.

Another detail that might sound weird at first: if you multiply any vector by 0 using this method (like the code above), it won’t do anything to that vector. It will just keep it where it is. (Trust me, I don’t know how this works, but it does)

Good luck!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.