Camera
Camera : Instance
Overview
Camera ๊ฐ์ฒด๋ 3D ๊ณต๊ฐ์์ ํ๋ ์ด์ด๊ฐ ๋ฐ๋ผ๋ณด๋ ์์ ์ ์ ์ํ๋ ์ธ์คํด์ค์ ๋๋ค.
์คํ ํ๊ฒฝ์์ ๊ฐ ํด๋ผ์ด์ธํธ๋ ๊ณ ์ ํ Camera๋ฅผ ๋ณด์ ํ๋ฉฐ, ์ด๋ Workspace.CurrentCamera ์์ฑ์ ํตํด ์ ๊ทผํ ์ ์์ต๋๋ค.
Camera์ ์์ฑ์ ์์ ํ์ฌ ์นด๋ฉ๋ผ์ ์์น์ ๋ฐฉํฅ์ ์กฐ์ ํ๊ฑฐ๋, ๋์ ๋ฐฉ์์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
Properties
CFrame
CFrame
์นด๋ฉ๋ผ์ ์์น์ ํ์ ์ ์ง์ ํ๋ ์์ฑ์ผ๋ก, 3D ๊ณต๊ฐ์์ ์นด๋ฉ๋ผ์ ์ขํ์ ๋ฐ๋ผ๋ณด๋ ๋ฐฉํฅ์ ์ ์ํฉ๋๋ค.
์ด ์์ฑ์ ์์ ํ์ฌ ์นด๋ฉ๋ผ๋ฅผ ์ง์ ์ด๋์ํฌ ์ ์์ผ๋, ๊ธฐ๋ณธ ์นด๋ฉ๋ผ ๋์์ ์บ๋ฆญํฐ์ ์ข ์๋๋ฏ๋ก CFrame์ ์๋์ผ๋ก ์ ์ดํ๋ ค๋ฉด CameraType ์์ฑ์ Scriptable๋ก ์ค์ ํ์ฌ ์๋ ๊ฐฑ์ ์ ๋นํ์ฑํํด์ผ ํฉ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(0, 150, 1000)
Focus
CFrame
ํ์ฌ ์ง์๋์ง ์์ต๋๋ค.
Code Samples
FieldOfView
number
FieldOfView(FOV)๋ ์นด๋ฉ๋ผ์ ์์ผ๊ฐ์ ์ ์ํ๋ ์์ฑ์ผ๋ก, ๊ธฐ๋ณธ๊ฐ์ 90๋์ด๋ฉฐ ์ค์ ๊ฐ๋ฅํ ๋ฒ์๋ 1๋์์ 169๋๊น์ง์ ๋๋ค.
์๋ฅผ ๋ค์ด, ์บ๋ฆญํฐ๊ฐ ์ ๋ ฅ ์ง์ฃผํ ๋ FOV ๊ฐ์ ๋์ด๋ฉด ์์ผ๊ฐ ํ์ฅ๋๋ฉด์ ํ๋ ์ด์ด๊ฐ ์ ์ด๋ ฅ์ ์๋ ๋ฏํ ์ฐ์ถ ํจ๊ณผ๋ฅผ ์ค ์ ์์ต๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
Camera.FieldOfView = 150
ViewportSize
Vector2
ํ์ฌ ํ๋ฉด์ ํฌ๊ธฐ๋ฅผ ๋ฐํํ๋ ์์ฑ์ ๋๋ค. (์ฝ๊ธฐ ์ ์ฉ)
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
print(Camera.ViewportSize)
CameraOffset
Vector3
์นด๋ฉ๋ผ์ ์๋ ์์น๋ฅผ ์ง์ ํ๋ ์์ฑ์ ๋๋ค.
์ฃผ๋ก TPS ๊ฒ์์์ ์บ๋ฆญํฐ๋ฅผ ํ๋ฉด ์ค์์์ ์ฝ๊ฐ ๋ฒ์ด๋ ์์น์ ๋ฐฐ์นํ ๋ ํ์ฉ๋ฉ๋๋ค. ์ด๋ฅผ ํตํด ์กฐ์ค์ ๊ณผ ์บ๋ฆญํฐ๊ฐ ์๊ฐ์ ์ผ๋ก ๊ฒน์น์ง ์๋๋ก ์ค์ ํ ์ ์์ต๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
Camera.CameraOffset = Vector3.new(90, 90, -120)
CameraSubject
Instance
์นด๋ฉ๋ผ๊ฐ ์ด์ ์ ๋ง์ถ ํผ์ฌ์ฒด๋ฅผ ์ง์ ํ๋ ์์ฑ์ ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก ์นด๋ฉ๋ผ๋ ๋ก์ปฌ ์บ๋ฆญํฐ์ Humanoid๋ฅผ ๋์์ผ๋ก ํ๋ฉฐ, CameraSubject๊ฐ BasePart๋ก ์ค์ ๋ ๊ฒฝ์ฐ ํด๋น ๊ฐ์ฒด๋ฅผ ์ถ์ ํฉ๋๋ค. ์๋ ๋์์ผ๋ก ๋๋๋ฆฌ๋ ค๋ฉด CameraSubject๋ฅผ ๋ค์ Humanoid๋ก ์ง์ ํ๋ฉด ๋ฉ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Part = Workspace:WaitForChild("Part")
local Camera = Workspace.CurrentCamera
Camera.CameraSubject = Workspace.Part
CameraType
Enum.CameraType
์นด๋ฉ๋ผ์ ๋์ ๋ฐฉ์์ ์ ์ํ๋ ์์ฑ์ผ๋ก, ๊ธฐ๋ณธ๊ฐ์ Custom์ ๋๋ค.
์ด ์์ฑ์ ๋ณ๊ฒฝํ๋ฉด Enum.CameraType ๊ฐ์ ๋ฐ๋ผ ์นด๋ฉ๋ผ ๋ชจ๋๊ฐ ์ ํ๋๋ฉฐ, ์ผ๋ถ ๋ชจ๋๋ ์ ์์ ์ผ๋ก ๋์ํ๊ธฐ ์ํด CameraSubject๊ฐ ํ์ํฉ๋๋ค.
CameraType์ด Scriptable๋ก ์ค์ ๋๋ฉด ๊ธฐ๋ณธ ์นด๋ฉ๋ผ ์ ์ด๊ฐ ๋นํ์ฑํ๋๊ณ , ๊ฐ๋ฐ์๊ฐ ์คํฌ๋ฆฝํธ๋ฅผ ํตํด CFrame์ ์ง์ ์์ ํ์ฌ ์นด๋ฉ๋ผ์ ์์น์ ๋ฐฉํฅ์ ์ ์ดํด์ผ ํฉ๋๋ค.
ํ์ฌ ์ง์๋๋ ๋ชจ๋๋ Custom๊ณผ Scriptable ๋ ๊ฐ์ง์ ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Methods
ViewportPointToRay
ํ๋ฉด์์ ๋น์จ ์ขํ(0~1)๋ฅผ ์ ๋ ฅ๋ฐ์, ์นด๋ฉ๋ผ ์์ ๋ฐฉํฅ์ ๋จ์ Ray๋ฅผ ์์ฑํด ๋ฐํํฉ๋๋ค.
Parameters
number
x
Ray๊ฐ ์์ฑ๋ ํ๋ฉด์์ ๊ฐ๋ก ์ขํ ๋น์จ์ ๋๋ค.
number
y
Ray๊ฐ ์์ฑ๋ ํ๋ฉด์์ ์ธ๋ก ์ขํ ๋น์จ์ ๋๋ค.
number
depth
ํ์ฌ ์ง์๋์ง ์์ต๋๋ค.
Return
Ray
์ ๋ ฅ๋ ํ๋ฉด ์ขํ๋ฅผ 3D ๊ณต๊ฐ์ผ๋ก ๋ณํํ ์ง์ ์ ์์์ ์ผ๋ก ํ์ฌ, ์นด๋ฉ๋ผ๊ฐ ๋ฐ๋ผ๋ณด๋ ๋ฐฉํฅ์ผ๋ก ํฌ์ฌ๋๋ Ray๋ฅผ ๋ฐํํฉ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local ViewportPointToRay = Camera:ViewportPointToRay(0.5, 0.5)
print("Ray Origin : ", ViewportPointToRay.Origin)
print("Ray Direction : ", ViewportPointToRay.Direction)
ScreenPointToRay
ํ๋ฉด์์ ์ขํ(ํฝ์ ๋จ์)๋ฅผ ์ ๋ ฅ๋ฐ์, ์นด๋ฉ๋ผ ์์ ๋ฐฉํฅ์ ๋จ์ Ray๋ฅผ ์์ฑํด ๋ฐํํฉ๋๋ค.
Parameters
number
x
Ray๊ฐ ์์ฑ๋ ํ๋ฉด์์ ๊ฐ๋ก ์ขํ(ํฝ์ ๋จ์)์ ๋๋ค.
number
y
Ray๊ฐ ์์ฑ๋ ํ๋ฉด์์ ์ธ๋ก ์ขํ(ํฝ์ ๋จ์)์ ๋๋ค.
number
depth
ํ์ฌ ์ง์๋์ง ์์ต๋๋ค.
Return
Ray
์ ๋ ฅ๋ ํ๋ฉด ์ขํ๋ฅผ 3D ๊ณต๊ฐ์ผ๋ก ๋ณํํ ์ง์ ์ ์์์ ์ผ๋ก ํ์ฌ, ์นด๋ฉ๋ผ๊ฐ ๋ฐ๋ผ๋ณด๋ ๋ฐฉํฅ์ผ๋ก ํฌ์ฌ๋๋ Ray๋ฅผ ๋ฐํํฉ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local ViewportSize = Camera.ViewportSize
local ScreenPointToRay = Camera:ScreenPointToRay(ViewportSize.X / 2, ViewportSize.Y / 2)
print("Ray Origin : ", ScreenPointToRay.Origin)
print("Ray Direction : ", ScreenPointToRay.Direction)
WorldToViewportPoint
3์ฐจ์ ์ขํ๋ฅผ ์ ๋ ฅ๋ฐ์ ํด๋น ์ง์ ์ ํ๋ฉด์ ์์น์, ๊ทธ ์ขํ๊ฐ ํ๋ฉด ๋ด๋ถ์ ํฌํจ๋๋์ง๋ฅผ ํจ๊ป ๋ฐํํฉ๋๋ค.
Parameters
Vector3
WorldPoint
์๋ ์ขํ์ ๋๋ค.
Return
Tuple
ํ๋ฉด์์ X, Y ์ขํ๋ฅผ ๋ด์ Vector3์ ์ ๋ ฅ๋ WorldPoint๊ฐ ํ๋ฉด ๋ด๋ถ์ ์กด์ฌํ๋์ง๋ฅผ ๋ํ๋ด๋ ๋ถ๋ฆฌ์ธ ๊ฐ์ ๋ฐํํฉ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local WorldPoint = Vector3.new(0, 50, -200)
local Vector, OnScreen = Camera:WorldToViewportPoint(WorldPoint)
print(Vector, OnScreen)
GetLargestCutoffDistance
(Deprecated) ์นด๋ฉ๋ผ์ CFrame ์์น์ Focus ์ง์ ์ฌ์ด์ ์์ผ๋ฅผ ๋ฐฉํดํ๋ ๋ฌผ์ฒด๊ฐ ์๋์ง ํ์ธํ ํ, ์ด๋ฅผ ํผํ๊ธฐ ์ํด ์นด๋ฉ๋ผ๋ฅผ Focus ๋ฐฉํฅ์ผ๋ก ์ผ๋ง๋ ์ด๋์์ผ์ผ ํ๋์ง๋ฅผ ๊ณ์ฐํ์ฌ ๋ฐํํฉ๋๋ค.
Parameters
array
InIgnoreList
์์ผ ์ฒ๋ฆฌ ๊ณผ์ ์์ ๋ฌด์ํ ์ธ์คํด์ค๋ค์ ๋๋ค.
Return
number
์นด๋ฉ๋ผ๊ฐ ์ฅ์ ๋ฌผ์ ๊ฐ๋ ค์ง์ง ์๋๋ก ํ๊ธฐ ์ํด, ํ์ฌ ์์น์์ Focus ๋ฐฉํฅ์ผ๋ก ์ผ๋ง๋ ๊ฐ๊น์ด ์ด๋ํด์ผ ํ๋์ง๋ฅผ ๊ณ์ฐํ ๊ฑฐ๋ฆฌ์ ๋๋ค.
Code Samples
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local IgonoreList = {}
local Distance = Camera:GetLargestCutoffDistance(IgonoreList)
print(Distance)
Events
See also
์นด๋ฉ๋ผLast updated