Camera Positioning help

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:

Any and all help is much appreciated

2 Likes

Bumping this post up because I have no Idea. Tried looking at other dev posts and found nothing, as well as trying my own solutions which didn’t work

1 Like
local camera = game.Workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable

camera.CFrame = CFrame.new()-- (Camera Origin, Camera Look direction)
2 Likes

This is what it looks like:

		local camera = game.Workspace.CurrentCamera

		camera.CameraType = Enum.CameraType.Scriptable

		camera.CFrame = CFrame.new(camera.CFrame.Position, EachCharm:GetPivot().Position)

This is more of what we are hoping for:

3 Likes

you have to make the origin of the part you wanna look at * z axis then for the lookat part make it the origin of the part you are looking for

1 Like

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.

1 Like

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.

1 Like

Used something like this, and are semi-happy with the results, at least enough that it properly functions as intended.

Here is a quick example of what im talking about



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 )

-10 Z vector


-50 Z Vector

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.