How to move with camera

HI,
I need to move with player camera (i exactly dont know, but i think that in jail break when i join, the camera is moving there in front of bank,…), i tried using view port frames, but best result was this


so how to do it
edit: withou view frame it look like this
(ik that the light isnt best but this is test place)

3 Likes

I’m not totally sure what you meant, but I guess you mean just moving the camera right?
To set a Camera’s CFrame (position + pan)

CFrame.new(position,lookAt) – both of these are Vector3s

If you want to move it from one place to another you can do

Camera:Interpolate(startCFrame, endCFrame, time)

So for example

workspace.Camera:Interpolate(CFrame.new(1,2,3), CFrame.new(5,6,7), 2)

This will move the camera from Position 1,2,3 to 5,6,7 in 2 seconds.

If you don’t know how to get the CFrames you want you can get your Studio’s Camera CFrames.
Type this in the command line

print(workspace.Camera.CFrame.p)

This will give you your camera’s current position, so you could get both CFrames for the Interpolate function easily. You can tweak them from here I guess.

Also, instead of Interpolate, you can use Tweening, but Interpolate() does the job for the most part and is much easier to do.

Sorry if I got your intent completely wrong though :V

seting cframe of main camera will only rotate it, i need to set its position and rotation or to use another cam, but to make it look better than:

Setting a CFrame of anything both sets it’s position AND rotation.
If you want to make the camera look at a specific position, or a part for example, you can do

workspace.Camera.CFrame = CFrame.new(position, workspace.CoolPart.Position)

I don’t know exactly you’re trying to do but here is what I can do.

local runservice = game:GetService("RunService")
runservice.RenderStepped:Connect(function()
    pcall(function()
        workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
        workspace.CurrentCamera.CFrame =   game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.p *    CFrame.new(0,0,10) -- or CFrame.new(10,0,0)
*CFrame.Angles(0,0,1.5) 
    end)
end)
1 Like

ik, but positing main camera will make it always look on player and i want to for example zoom it on turbine or reactor,…

Oh, when manipulating the camera you must always set

Camera.CameraType = ‘Scriptable’

When you are done displaying a cutscene or something, switch back to normal by doing

Camera.CameraType = ‘Custom’

1 Like

ok so how to set camera back to user control

Camera.CameraType = ‘Custom’

1 Like

If you want it to be like that

_G.First = false
local m = game.Players.LocalPlayer:GetMouse()
m.KeyDown:Connect(function(k)
if k == "k" --key make it uncaps
if _G.First == true then
 _G.First == false
else
 _G.First == true
end
end)

local runservice = game:GetService("RunService")
runservice.RenderStepped:Connect(function()
    pcall(function()
if _G.First == false then
        workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
        workspace.CurrentCamera.CFrame =   game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.p *    CFrame.new(0,0,10) -- or CFrame.new(10,0,0)
*CFrame.Angles(0,0,1.5) 
else
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
    end)
end)

what are you even trying to do?