Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to use a part as a camera?

Asked by
cfiredog 274 Moderation Voter
7 years ago

I'm basically trying to make the camera face whichever way a part is faced and positioned.

I've managed to get the camera to be positioned where the part is, but I can't figure out how to face the camera in the direction that the part is facing. I tried setting the camera rotation to equal that of the part, but the camera loves to stay focused on my character. I've also tried changing the CameraSubject to that of the part- as well as changing the camera type- with no luck. Any suggestions?

My Code:

camera  = game.Workspace.CurrentCamera
CamPart = game.Workspace.CamPart

position = CamPart.Position
rotation = CamPart.Rotation

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame     = CFrame.new(position, rotation)

1 answer

Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

Simply set the camera CFrame to the CamPart's CFrame. CFrames carry over rotations.

camera  = game.Workspace.CurrentCamera
CamPart = game.Workspace.CamPart

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CamPart.CFrame
0
This answer sounded promising! However, the look vector still changes to point towards where my character spawns upon pressing play. The only thing I could think of that's causing this is that the CameraSubject is set to my Humanoid before changing to CamPart cfiredog 274 — 7y
0
I see you edited your post, and that seemed to work! Thank you! cfiredog 274 — 7y
0
Yup, np LittleBigDeveloper 245 — 7y
Ad

Answer this question