WeldConstraints는 두개의 Part를 붙일때 사용된다. WeldConstraint는 Part가 상대 Part의 상대적으로 같은 위치와 방향을 유지하도록 한다. 이 말은, 만약 WeldConstraint를 통해 붙여진 두개의 Part가 있다면, 하나의 Part가 움직이면 다른 Part도 같은 크기(거리, 방향)으로 따라 움직이게 된다는 뜻이다.
두 개의 Part가 서로 떨어져 있어도 WeldConstraints를 통해 용접시킬 수 있다.
WeldConstraints를 생성하는 가장 평범한 방법은 Model 탭에 있는 Studio Create menu를 통한 방법이다. 이 tool은 tool이 활성화 될 때 선택한 Part 수에 따라 다르게 작동한다.
- Weld tool을 클릭 할 때 Part를 선택하지 않으면 다음에 클릭한 두 Part가 함께 용접된다. 동일한 Part를두 번 클릭하면 용접이 되지 않는다.
- Weld tool을 클릭 할 때 한 Part를선택하면 클릭 한 다음 Part가 선택한 Part에 용접된다.
- Weld tool을 클릭 할 때 여러 Part를 선택한 경우 해당 선택 항목에서 접하거나 겹치는 모든 Part들이 함께 용접된다.
Repositioning Welded Parts
Roblox는 Part가 Position 또는 CFrame을 사용하여 이동되었는지 여부에 따라 용접 된 Part 이동을 다르게 처리한다.
용접 된 Part의 Position이 업데이트되면 Part는 이동하지만 연결된 Part는 함께 이동하지 않는다. 용접은 Part의 새 Position를 기반으로 다른 Part의 오프셋을 다시 계산한다.
offset??
-- 두개의 Part를 생성하고 같은 높이에 위치시킨다.
local partA = Instance.new("Part")
local partB = Instance.new("Part")
partA.Position = Vector3.new(0, 10, 0)
partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
-- 두 Part를 용접시킨다.
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
-- 첫번째 파트의 Position을 업데이트한다; 첫번째 Part는 움직일 것이지만, 두번째 Part는 시작된 위치에 머무르게 된다.
partA.Position = Vector3.new(0, 20, 0)
반대로, Part의 CFrame이 업데이트 된다면, Part는 움직이게 되고, 해당 Part에 용접된 Part 또한 움직일 것이다. 용접된 Part는 처음 용접했을 때와 같은 offset을 유지하면서 움직여지게 된다.
-- 두개의 Part를 생성하고 같은 높이에 위치시킨다.
local partA = Instance.new("Part")
local partB = Instance.new("Part")
partA.Position = Vector3.new(0, 10, 0)
partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
-- 두 Part를 용접시킨다.
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
-- 첫번째 Part의 CFrame을 업데이트한다; 두번째 Part는 용접할때와 같은 offset을 유지하며 첫번째 Part와 같이 움직이게 된다.
partA.CFrame = CFrame.new(0, 20, 0)
참고 링크
developer.roblox.com/en-us/api-reference/class/WeldConstraint
WeldConstraint
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on t
developer.roblox.com
추가 공부 사항
offset
DataModelMesh.Offset
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on t
developer.roblox.com
'API 문서' 카테고리의 다른 글
ContextActionService (0) | 2021.04.17 |
---|---|
ManualWeld (0) | 2021.04.11 |
TweenService (0) | 2021.04.11 |
Debris (0) | 2021.04.11 |
UserInputService (0) | 2021.04.10 |
댓글