How to rotate a 2D-Camera Angle on the Y-axis?

Hello people,

I have some troubles with a 2D Camera that changes its its Orientation when the player touches the button.

Currently, the view for the character is in the Front View for the Z-axis before touching the button.
What I want is to have the view on the Right Side of the Z-axis after touching the button

I have tried using CFrame.fromOrientation() and CFrame.Angles() both having 90 degrees on the Y-axis.

This is the View without tampering with the CFrame’s Angles
help1

This is the view of the Angles at (0,90,0)
It shows the left side of the Baseplate.

This is the Camera Script

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera


plr.CharacterAdded:Wait()
plr.Character:WaitForChild("HumanoidRootPart")

cam.CameraSubject = plr.Character.HumanoidRootPart
cam.CameraType = Enum.CameraType.Attach
cam.FieldOfView = 40

local RunService = game:GetService("RunService")

local function onUpdate()
	if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
		cam.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position) * CFrame.new(0,3,50) * CFrame.fromOrientation(0,90,0)
	end
end
 
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onUpdate)

I suppose that the Position of the Camera affects the View Angle of the Camera.
Thanks for helping! (In advance)

Would you be able to define more precisely what you mean by wanting to “have the view on the right side of the z axis”?

math.rad(90)
By default, the angles transforms are done using radians, so rather than a 90* angle, you’re using 90 radians to rotate by.
Thats around 5156*

I think the best way to define that rotation + offset would be like this;

local CameraAlteration = CFrame.new(0, 3, 50) * CFrame.fromOrientation(0, math.rad(90), 0)
local function onUpdate()
	if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
		cam.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position) * CameraAlteration
	end
end
1 Like

Sorry for being unclear, in other words, I meant by having the view of the Character facing towards the screen.

help3

Ah, I did not know that.

I’ve just tested it and it’s exactly what I was looking for! Thank you very much!
Just needs to swap the Z-axis with the X-axis.

1 Like