I made a simple thing to switch the camera to a part but I’ve been trying to figure out how to rotate that Part when you move the mouse.
You can toggle the camera but I cant figure out how to rotate it, I’ve tried assigning the coordinates to the part which did move the part but not when it was toggled on and also put me somewhere in the middle of nowhere
Any sort of help or feedback would be much apricated. Thank you
You would need two values, a X value and a Y value. For the transformation on the part, you start with a CFrame of no rotation, them multiply it by the angles desired. What I mean by that is, apply the rotation transformations onto the part.
local part = workspace.Part
local PartCFrame = CFrame.new(part.Position) --CFrame with an empty rotation matrix
PartCFrame *= CFrame.Angles(0,math.rad(90),0) --Turns the camera left and right
PartCFrame *= CFrame.Angles(math.rad(0),0,0) --Tilts the camera up and down
part.CFrame = PartCFrame
I would use a Vector2 value for the mouse rotation, incrementing the values based on mouse movement. The mouse movement can be used through UserInputService:GetMouseDelta(). Then, you would input the X and Y values from the Vector2 into the transformations above, but make sure to flip their signs.
2 Likes