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

Why does this not face the part?

Asked by 8 years ago

local target = workspace.THEPARTINEED local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target while wait() do camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part end

The camera is still but is not looking at the part?

Any ideas?

1 answer

Log in to vote
0
Answered by 8 years ago

Scriptable camera will ignore both CameraSubject and Focus. It's whole purpose is to be fully controlled by your own code. This should work:

local target = workspace.THEPARTINEED
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position, target.Position + target.CFrame.lookVector) 
end

Right now it will face same direction the part is oriented at, since I wasn't sure where exactly the camera should be located and where it should look.

Also consider using RenderStepped, since wait() is only 1/24 of a second, while roblox renders more often than that. Check these out:

http://wiki.roblox.com/index.php?title=API:Class/RunService/RenderStepped http://wiki.roblox.com/index.php?title=API:Class/RunService/BindToRenderStep

I'd personally use runService:BindToRenderStep(), otherwise do runService.RenderStepped:wait().

0
Thank you very much but it doesn't work :/ It just locks the camera on the player. jjwood1600 215 — 8y
0
Hm, I guess you set the target to player's head? Well, that is what it should do, look at the part. At least that's what I understood from your post. ZarsBranchkin 885 — 8y
0
Yeah, although I copied it exactly and it locked it to the players head and not the part :/ I will carry on trying to figure it out.. jjwood1600 215 — 8y
Ad

Answer this question