I’ve managed to get the rotation correct, but I’m over my head as to how to offset the camera from the part (I’d like to place it behind the plane as I mocked up in the image). As of now, whenever I start the game the camera is locked in first person like so:
I’ve tried to insert a humanoid into the part and use CameraOffset, as well as using the CFrame property by itself, but none of them work and instead throw an error.
This is the code I’m using right now, without my attempts to set the position. It’s a LocalScript placed in StarterPlayerScripts.
local camera = workspace.CurrentCamera
local run = game:getService("RunService")
local plane = workspace.plane
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = plane
local function OnChanged()
camera.CFrame = plane.CFrame * CFrame.Angles(0,55,0)
wait()
end
run.Heartbeat:Connect(OnChanged)
I think it will be easier if you use an attachment within the mesh part to get the camera CFrame. Just set the camera the attachments worldCFrame and you will get the offset you need. Plus if you don’t like it you can drag it around in studio until desired position.
local camera = workspace.CurrentCamera
local run = game:getService("RunService")
local plane = workspace.plane
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = plane
local function OnChanged()
camera.CFrame = plane.Attachment.WorldCFrame--add the attachment to the plane
--wait()-- you don't need wait() in a heartbeat connection
end
run.Heartbeat:Connect(OnChanged)
Alternatively, you can use a GUI to change the CFrame offset through the formula until you get a camera offset you want which you can do using this resource:
local function OnChanged()
--use the GUI to position and change the 6 numbers
--until the desired position where you like it
camera.CFrame = plane.CFrame * CFrame.new(a,b,c)*CFrame.Angles(d,e,f)
end