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

HELPPP, MY CAMERA INSTANCE WON'T MOVE?!

Asked by 4 years ago
Edited 4 years ago
cam = game.Workspace.CurrentCamera
pos = Vector3.new(0,20,0) -- Rise Camera Upwards 20 studs from origin
lookAt = Vector3.new(0,10,0) -- Orient the cam 10 upwards from origin
cam.CFrame = CFrame.new(pos) * CFrame.Angles(lookAt)

When I do this the camera stops following me and stays where it is, how can I move it to a new pos while keeping it followed on me??!!! Please!

I've already made it scriptable, but it works but it doesn't work the way I want it to...

0
The second argument of a CFrame() is the lookat position. Like this: CFrame.new(Position,LookAt). What you can do if you want the camera to look 10 studs above the object is: Cam.CFrame = CFrame.new(pos, lookAt + vector3.new(0,10,0)) noammao 294 — 4y

2 answers

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
4 years ago

Scriptable camera does not move automatically, you'd have to update its position and orientation every frame. Before you do that, check out other camera types, to make sure none of them are what you are looking for:

Camera Types

If none of them are to your liking, you'd have to connect your camera function to RenderStepped(). Why not wait() loop or Heartbeat()? Because RenderStepped will execute, before rendering and it is recommended for (and only) camera manipulation. Below LocalScript will create overhead camera.

cam = game.Workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
cam.CameraSubject = workspace 

local RunService = game:GetService("RunService")
local Players = game:getService("Players")
local character = Players.LocalPlayer.character or player.CharacterAdded:wait()
local root = character:WaitForChild("HumanoidRootPart")

local riseVector = Vector3.new(0,20,0)

local function onRenderStep()
    cam.CFrame = CFrame.new(root.Position +  riseVector,root.Position)
end
RunService.RenderStepped:Connect(onRenderStep)
0
Sounds about right. I will give it a go! Fate2Seal 5 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

just use

cam.CFrame = CFrame.new(pos, lookAt)

make sure make camera Scriptable or else it will reset back to the character in the script CFrame.Angles is used to rotate the camera/part anyways CFrame.new() is like all in one, position, look at it, and etc. and then don't forget return the camera into Custom again by adding some wait(NUMBER)

Answer this question