WorldObject
WorldObject
์๋์ ๋ฐฐ์น๋ ์ค๋ธ์ ํธ์ ๊ณตํต๋ ์์ฑ๊ณผ ์ด๋ฒคํธ, ํจ์๋ค์ด์์
์ด๋ฒคํธ
OnUpdateEvent
์์ฑ ํ ๋งค ํ๋ ์๋ง๋ค ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function(updateTime), updateTime ์ number ์ ๋๋ค.
-- ์ํ --
local cube = Workspace.Cube
local playTime = 0
local function UpdateEvent(updateTime) --OnUpdateEvent๋ก ์ฐ๊ฒฐ๋ ํจ์๋ updateTime ์ธ์๊ฐ ๊ณ ์ ์ ์ผ๋ก ๋ค์ด๊ฐ์.
playTime = playTime + updateTime --์๊ฐ์ ๊ธฐ๋กํด์.
end
cube.OnUpdateEvent:Connect(UpdateEvent) --Game์ด๋ ์ค๋ธ์ ํธ์ ๋งคํ๋ ์๋ง๋ค ํธ์ถ๋๋ ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
OnDestroyEvent
์ญ์ ๋ ๋ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function() ์ ๋๋ค.
-- ์ํ --
local cube = Workspace.Cube
local function DestroyEvent()
print("Destroy!")
end
cube.OnDestroyEvent:Connect(DestroyEvent) --์ค๋ธ์ ํธ์ ํด๋น ์ค๋ธ์ ํธ๊ฐ ํ๊ดด๋์๋ ํธ์ถ๋๋ ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
Game:DeleteObject(cube)
OnEnableEvent
Enable ๋ ๋ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function() ์ ๋๋ค.
-- ์ํ --
local cube = Workspace.Cube
local function InitObj(self)
print("Enable")
end
cube.OnEnableEvent:Connect(InitObj) --ํด๋น ์ค๋ธ์ ํธ๊ฐ Enable๋ ๋ ํธ์ถ๋๋ ํจ์๋ฅผ ์ฐ๊ฒฐํฉ๋๋ค.
wait(1)
cube.Enable = true
OnDisableEvent
Disable ๋ ๋ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function() ์ ๋๋ค.
-- ์ํ --
local cube = Workspace.Cube
local function BackupToPoolList(self)
print("Disable")
end
cube.OnDisableEvent:Connect(BackupToPoolList) --ํด๋น ์ค๋ธ์ ํธ๊ฐ Disable๋ ๋ ํธ์ถ๋๋ ํจ์๋ฅผ ์ฐ๊ฒฐํฉ๋๋ค.
wait(1)
cube.Enable = false
์์ฑ
Enable
๊ฐ์ฒด ํ์ฑํ ์ฌ๋ถ
-- ์ํ --
Workspace.Cube.Enable = false --์ค๋ธ์ ํธ์ ์ํ๋ฅผ ๋นํ์ฑํํด์. (์์ ์ค๋ธ์ ํธ๊ฐ ์๋ค๋ฉด ์์๋ค์ ์ํ๋ ๋ชจ๋ false๊ฐ ๋ผ์. ๋จ, ์ถฉ๋์์ญ์๋ ์ํฅ์ด ์์ด์.)
Transform
๊ฐ์ฒด์ Matrix
-- ์ํ --
local cube = Workspace.Cube
local targetTransform = cube.Transform
targetTransform.Location = Vector.new(300, 0, 100)
targetTransform.Rotation = Vector.new(55, 100, 0)
cube.Transform = targetTransform --์ค๋ธ์ ํธ๋ฅผ ๋ณด๊ฐ์ผ๋ก ์ด๋์์ผ์. (์บ๋ฆญํฐ๋ ๋ณด๊ฐ์์ด ์์ง์ฌ์.)
LocalTransform
๊ฐ์ฒด์ Local Transform
-- ์ํ --
local Cube = Workspace.Cube
print(Cube.LocalTransform)
local LocalTR = Workspace.SpawnPoint.LocalTransform
Cube.LocalTransform = LocalTR
Location
๊ฐ์ฒด์ ์์น Vector
-- ์ํ --
local Cube = Workspace.Cube
Cube.Location = Vector.new(0, 300, 200)
LocalLocation
๊ฐ์ฒด์ ๋ก์ปฌ์ขํ Vector
-- ์ํ --
local Cube = Workspace.Cube
Cube.LocalLocation = Vector.new(0, 300, 200)
Rotation
๊ฐ์ฒด์ ํ์ Vector
-- ์ํ --
local Cube = Workspace.Cube
Cube.Rotation = Vector.new(0, 100, 0)
LocalRotation
๊ฐ์ฒด์ ๋ก์ปฌ ํ์ Vector
-- ์ํ --
local Cube = Workspace.Cube
Cube.LocalRotation = Vector.new(0, 100, 0)
Scale
๊ฐ์ฒด์ ํฌ๊ธฐ Vector
-- ์ํ --
local Cube = Workspace.Cube
local scale = Cube.Scale --ํด๋น ์ค๋ธ์ ํธ์ ํฌ๊ธฐ๋ฅผ 100์ผ๋ก ๋๋ ์ Vector๋ก ๋ฐํํด์.(์๋ฅผ ๋ค์ด x๊ฐ์ด 100์ด๋ฉด 1๋ก ๋ฐํ๋ผ์.)
print(scale)
Cube.Scale = Vector.new(5, 5, 5) --์ค๋ธ์ ํธ์ ํฌ๊ธฐ๋ฅผ ์ค์ ํด์.
Visible
๊ฐ์ฒด์ ๊ฐ์์ฑ
-- ์ํ --
Workspace.Cube.Visible = false --์ค๋ธ์ ํธ๋ฅผ ๋ณด์ด์ง ์๊ฒ ํด์.
ํจ์
number GetKey()
๊ฐ์ฒด์ ํค ๊ฐ์ ์ป์ ์ ์์ด์.
-- ์ํ --
print(Workspace.Floor:GetKey())
void SetTransformWithCollisionCheck(bool CollisionCheck)
ํ์ฌ ๋งคํธ๋ฆญ์ค์์ ์ค์ ๋ ๋งคํธ๋ฆญ์ค๋ก ๋ณด๊ฐ์ด ๋๋ ๋งคํธ๋ฆญ์ค๋ฅผ ์ค์ ํ ์ ์์ด์ ์ค์ ํ ์ ์์ด์. (Matrix ๊ฐ, bool ์ถฉ๋ ์ฒ๋ฆฌ ์ฌ๋ถ)
-- ์ํ --
local cube = Workspace.Cube
local targetTransform = cube.Transform
targetTransform.Location = Vector.new(300, 0, 100)
cube:SetTransformWithCollisionCheck(targetTransform, true) --์ค๋ธ์ ํธ๋ฅผ ๋ณด๊ฐ์ผ๋ก ์ด๋์์ผ์. (์บ๋ฆญํฐ๋ ๋ณด๊ฐ์์ด ์์ง์ฌ์.)
void SetLocalTransformWithCollisionCheck(bool CollisionCheck)
ํ์ฌ ๋งคํธ๋ฆญ์ค์์ ์ค์ ๋ ๋งคํธ๋ฆญ์ค๋ก ๋ณด๊ฐ์ด ๋๋ ๋งคํธ๋ฆญ์ค๋ฅผ ๋ก์ปฌ์ขํ๊ธฐ์ค์ผ๋ก ์ค์ ํ ์ ์์ด์ ์ค์ ํ ์ ์์ด์. (Matrix ๊ฐ, bool ์ถฉ๋ ์ฒ๋ฆฌ ์ฌ๋ถ)
-- ์ํ --
local cube = Workspace.Cube
local targetLocalTransform = cube.LocalTransform
targetLocalTransform.Location = Vector.new(300, 0, 100)
cube:SetLocalTransformWithCollisionCheck(targetLocalTransform, true) --์ค๋ธ์ ํธ๋ฅผ ๋ณด๊ฐ์ผ๋ก ์ด๋์์ผ์. (์บ๋ฆญํฐ๋ ๋ณด๊ฐ์์ด ์์ง์ฌ์.)
void Teleport()
์๊ฐ์ด๋ ํ๋ ๋งคํธ๋ฆญ์ค๋ฅผ ์ค์ ํ ์ ์์ด์. (Matrix ๊ฐ)
-- ์ํ --
local cube = Workspace.Cube
local targetTransform = cube.Transform
targetTransform.Location = Vector.new(0, 100, 0)
cube:Teleport(targetTransform) --์ค๋ธ์ ํธ๋ฅผ ๋ณด๊ฐ์์ด ๋ฐ๋ก ์ด๋์์ผ์.
void SetLocationWithCollisionCheck(Vector position, bool bCollisionCheck)
๊ฐ์ฒด์ ์์น๋ฅผ ์ค์ ํ ์ ์์ด์. (์ค์ ํ ์์น Vector ๊ฐ, ์ถฉ๋ ์ฒ๋ฆฌ ์ฌ๋ถ)
-- ์ํ --
local Cube = Workspace.Cube
local targetLocation = Vector.new(0, 300, 200)
Cube:SetLocationWithCollisionCheck(targetLocation, true)
void SetTag(string Tag)
๊ฐ์ฒด์ tag๋ฅผ ์ค์ ํด์. (์ค์ ํ tag)
-- ์ํ --
print(Workspace.Floor:GetTag())
Workspace.Floor:SetTag("SomeTag")
print(Workspace.Floor:GetTag())
string GetTag()
๊ฐ์ฒด์ ์ค์ ๋ tag๋ฅผ ์ป์ ์ ์์ด์.
-- ์ํ --
print(Workspace.Floor:GetTag())
Workspace.Floor:SetTag("SomeTag")
print(Workspace.Floor:GetTag())
void ConnectEventFunction(string customevent, function TargetFunction)
์ ์ ๊ฐ ์ถ๊ฐํ ์ค๋ธ์ ํธ ์ปค์คํ ์ด๋ฒคํธ์ ํจ์๋ฅผ ์ฐ๊ฒฐํ ์ ์์ด์. (์ด๋ฒคํธ ์ด๋ฆ, ์ฐ๊ฒฐ ํจ์)
-- ์ํ --
--์๋ฒ ์คํฌ๋ฆฝํธ์์
local cube = Workspace.cube
--์๋ฒ์์ ์ด๋ฒคํธ ์์ฑ์ ์ฒซ ์ธ์๋ก player๊ฐ ๋ค์ด๊ฐ์.
local function ServerSomeFunc(player)
print("Call ServerSomeFunc")
end
cube:ConnectEventFunction("ServerSomeFunc", ServerSomeFunc) --์ค๋ธ์ ํธ์ "ServerSomeFunc"๋ผ๋ ์ด๋ฒคํธ ์ด๋ฆ์ผ๋ก SomeFunc ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
--์ค๋ธ์ ํธ๊ฐ ์๋ Game์๋ ์ฐ๊ฒฐํ ์ ์์ด์.
--๊ฐ์ ๋์์ ๋ฑ๋ก๋ ์ด๋ฒคํธ๋ง ํธ์ถํ ์ ์์ด์.
--๊ฐ์ ์ด๋ฆ์ผ๋ก ์ฌ๋ฌ ํจ์๋ฅผ ์ฐ๊ฒฐํ ์ ์์ง๋ง ์ด ๊ฒฝ์ฐ ํธ์ถํ ๋ ์ฐ๊ฒฐ๋ ํจ์๊ฐ ๋ชจ๋ ํธ์ถ๋ผ์.
-----------------------------------
--ํด๋ผ ์คํฌ๋ฆฝํธ์์
local cube = Workspace.cube
--ํด๋ผ์์ ์ด๋ฒคํธ ์์ฑ์ player ์ธ์๋ฅผ ์ฐ์ง ์์๋ ๋ผ์.
local function ClientSomeFunc()
print("Call ClientSomeFunc")
end
cube:ConnectEventFunction("ClientSomeFunc", ClientSomeFunc)
void LookAt(vector location)
์ค๋ธ์ ํธ๊ฐ ํด๋นํ๋ ์์น๋ฅผ ๋ฐ๋ผ๋ณด๊ฒ ํ ์ ์์ด์. (๋ฐ๋ผ๋ณผ ์์น Vector)
-- ์ํ --
local Cube = Workspace.Cube
wait(2)
Cube:LookAt(Workspace.SpawnPoint.Location)
์ฌ์ฉ ๊ฐ๋ฅํ ๋ถ๋ชจ ์ค๋ธ์ ํธ ๊ธฐ๋ฅ๋ค
์์ฑ
์ด๋ฒคํธ
์ด๋ฆ
์ค๋ช
ํจ์
์ด๋ฆ
์ค๋ช
์ถ๊ฐ๋ ๊ฐ์ด ๋ณ๊ฒฝ ๋ ๋ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. (Value ์ด๋ฆ, ์ฐ๊ฒฐ ํจ์)
์ด๋ฆ์ผ๋ก ์์ ๊ฐ์ฒด๋ฅผ ์ป์ ์ ์์ด์. (์ฐพ๊ณ ์ถ์ ์์ ๊ฐ์ฒด ์ด๋ฆ)
์์ ๊ฐ์ฒด์ ๋ฆฌ์คํธ๋ฅผ ์ป์ ์ ์์ด์.
์บ๋ฆญํฐ์ธ์ง ํ์ธํ ์ ์์ด์.
์คํ ํฑ ๋ฉ์์ธ์ง ํ์ธํ ์ ์์ด์.
FX์ธ์ง ํ์ธํ ์ ์์ด์.
Sound์ธ์ง ํ์ธํ ์ ์์ด์.
ํฌ์ธํธ ๋ผ์ดํธ์ธ์ง ํ์ธํ ์ ์์ด์.
์คํฌํธ ๋ผ์ดํธ์ธ์ง ํ์ธํ ์ ์์ด์.
์ํผ์ค UI์ธ์ง ํ์ธํ ์ ์์ด์.
์คํฌ๋ฆฐ UI์ธ์ง ํ์ธํ ์ ์์ด์.
ํฐ์น UI์ธ์ง ํ์ธํ ์ ์์ด์.
์์ดํ ์ธ์ง ํ์ธํ ์ ์์ด์.
NPC์ธ์ง ํ์ธํ ์ ์์ด์.
์คํธ๋ฆฝํธ์ธ์ง ํ์ธํ ์ ์์ด์.
Collider์ธ์ง ํ์ธํ ์ ์์ด์.
Widget์ธ์ง ํ์ธํ ์ ์์ด์.
Camera์ธ์ง ํ์ธํ ์ ์์ด์.
ํด๋น ์ค๋ธ์ ํธ๊ฐ ์ ํจํ์ง ํ์ธ ํ ์์์ด์.
ํด๋น ์ค๋ธ์ ํธ์ ๊ฐ์ด ์ ํจํ์ง ํ์ธํ ์ ์์ด์.
ํด๋น ๊ฐ์ฒด์ ์๋ฒ, ํด๋ผ์ด์ธํธ ๊ฐ ๋๊ธฐํ๊ฐ ๊ฐ๋ฅํ ๋ฒกํฐ๋ฅผ ์ถ๊ฐํด์. (์ถ๊ฐํ Value ์ด๋ฆ, Vector ๋ฐ์ดํฐ, Enum.ReplicateType.ํ์ , ๋๊ธฐํ ์๊ฐ)
ํด๋น ๊ฐ์ฒด์ ์๋ฒ, ํด๋ผ์ด์ธํธ ๊ฐ ๋๊ธฐํ๊ฐ ๊ฐ๋ฅํ ์ค์๋ฅผ ์ถ๊ฐํด์. (์ถ๊ฐํ Value ์ด๋ฆ, number ๋ฐ์ดํฐ, Enum.ReplicateType.ํ์ , ๋๊ธฐํ ์๊ฐ)
ํด๋น ๊ฐ์ฒด์ ์๋ฒ, ํด๋ผ์ด์ธํธ ๊ฐ ๋๊ธฐํ๊ฐ ๊ฐ๋ฅํ bool๋ฅผ ์ถ๊ฐํด์. (์ถ๊ฐํ Value ์ด๋ฆ, bool ๋ฐ์ดํฐ, Enum.ReplicateType.ํ์ , ๋๊ธฐํ ์๊ฐ)
ํด๋น ๊ฐ์ฒด์ ์๋ฒ, ํด๋ผ์ด์ธํธ ๊ฐ ๋๊ธฐํ๊ฐ ๊ฐ๋ฅํ ๋ฌธ์์ด์ ์ถ๊ฐํด์. (์ถ๊ฐํ Value ์ด๋ฆ, string ๋ฐ์ดํฐ, Enum.ReplicateType.ํ์ , ๋๊ธฐํ ์๊ฐ)
ํด๋น ๊ฐ์ฒด์ ์๋ฒ, ํด๋ผ์ด์ธํธ ๊ฐ ๋๊ธฐํ๊ฐ ๊ฐ๋ฅํ ์ปฌ๋ฌ๋ฅผ ์ถ๊ฐํด์. (์ถ๊ฐํ Value ์ด๋ฆ, Color ๋ฐ์ดํฐ, Enum.ReplicateType.ํ์ , ๋๊ธฐํ ์๊ฐ)
Last updated
Was this helpful?