CFrame.Angles not working

Hello!
CFrame.Angles won’t work for me. I’m trying to make my camera face the pan, but instead it faces away from it. I decided to use CFrame.Angles to change the rotation, but instead it doesn’t change anything!
Script:

workspace.CurrentCamera.CFrame = (workspace.ShopCamera.Pans.DiamondPan.CFrame - Vector3.new(-1,0,0) )* CFrame.Angles(0,math.rad(90),0)

Can’t understand why, I’ve tried changing the 90, to random integers, but it still won’t change anything!

1 Like

You Might want to rotate the part that the camera goes to 180 or until the front surface is facing where you want the camera to face

I cannot do that because my part will look weird otherwise. How do I turn the camera without rotating the part?

Maybe make a part that has the transparency set to 1 and cancollide to false and use that as the part that the camera goes to

Yeah but I’m making a shop so that won’t really work for me very well.

Let’s break down your code:

A = workspace.CurrentCamera.CFrame
B = workspace.ShopCamera.Pans.DiamondPan.CFrame
C = CFrame.Angles(0,math.rad(90),0)
p = Vector3.new(-1,0,0)

A = (B - p)C

When we apply orientation matrices, we start from the right and go to the left. This means that we start in orientation C, or looking 90 degrees to the right from the identity orientation. Next, we view this 90 degree rotation relative to the (B - p) orientation, or in other words, the space of B moved to the right by one. In this space, we are looking to the right. The actual direction we are looking depends on the orientation of B, but we are looking 90 degrees “right” from it, using B’s definition of “up”.

What we want to do is have a position looking left in the world space and moved to the right of B by 1 unit. Since this may be too close and within clipping range, we’ll move 10 units instead initially. Here’s how we do it:

  1. We want our orientation to be in terms of world space, looking left.
B = CFrame.Angles(0, -math.pi/2, 0)
  1. Our orientation is at the origin right now, but we want it to be at the DiamondPans’s position, and right 10 units in the world space.
p = workspace.workspace.ShopCamera.Pans.DiamondPan.Position + Vector3.new(10, 0, 0)
  1. Put the orientation and offset together
C = B + p
  1. Expand it
workspace.CurrentCamera.CFrame =
    CFrame.Angles(0, -math.pi/2, 0)
    + workspace.workspace.ShopCamera.Pans.DiamondPan.Position
    + Vector3.new(10, 0, 0)

(Note: this isn’t tested and depends on Roblox’s definitions of the coordinate system and camera which I’m not used to working in lately. Do let me know if there is an issue with it)

3 Likes