Hey developers! I feel like this should be simple, but I have been stuck for hours. Basicially I want a camera facing the front of this model here (shown in teal parts for an example, parts don’t exist in the real deal game). However each model faces a different way, and some are up higher, or lower. And then of course I need the camera to be a little bit back away from the model itself.
How can I do this. I have tried so many things, and nothing is close. this is what I have right now, and it don’t work
local camera = game.Workspace.CurrentCamera
local x, y, z = EachCharm:GetPivot().Rotation:ToOrientation()
camera.CameraType = "Scriptable"
camera.CFrame = CFrame.lookAt(EachCharm:GetPivot().Position, Vector3.new(math.deg(x), math.deg(y), math.deg(z))) * CFrame.new(Vector3.new(0, 1.2, 3)) * CFrame.Angles(math.rad(-40), math.rad(10), 0)
Image of where the cameras should go, and the model itself:
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new()-- (Camera Origin, Camera Look direction)
Sorry. I read your post a lot and I am still confused. Would I just something like CFrame.lookat(). and the ‘part I want to look at’ is a model, which requires (unless another method) of :GetPivot(). If possible could you provide a code example of what I should do? I don’t understand CFrames a ton.
You need to set a primary part of the model by going into the model and making PrimaryPart be one of the straight parts on the model (you can even add an invisible part so u can customize how u want it to be), then do this:
local pivot = model:GetPivot()
camera.CFrame = CFrame.lookAt(pivot.Position + pivot.LookVector*10,pivot.Position,camera.CFrame.UpVector)
With *10 being the distance of the camera from the model. Also if the camera is on the wrong side you can just change *10 to *-10 to make it look from the back side or change .LookVector to .RightVector to make it look from right.
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
local Target = workspace:WaitForChild("Part") --The part we want to look at
Camera.CFrame = CFrame.new((Target.CFrame * CFrame.new(0,0,-50).Position),Target.Position)-- CFrame.new(Where you want to camera to look from(must be a position), Where you want the camera looking at )