A PVInstance ("위치 속도 인스턴스")는 생성할 수 없는 추상 클래스입니다.세계에 물리적 위치가 있는 모든 개체의 기반, 특히 BaseParts 및 Models.
요약
메서드
PVInstance의 피벗을 가져옵니다.
피벗이 지금 지정된 PVInstance 에 위치하도록 모든 하위 요소 PVInstances 와 함께 변환하여 피벗이 지금 지정된 CFrame 에 위치합니다.
속성
메서드
GetPivot
이 함수는 PVInstance의 피벗을 가져옵니다. 이는 종종 모델을 이동하기 위해 PVInstance:PivotTo()와 함께 사용됩니다.
Models 및 BaseParts 는 모두 PVInstances ("위치 속도 인스턴스")이며, 따라서 둘 다 이 기능이 있습니다.
반환
코드 샘플
-- This code should be placed in a LocalScript under StarterPlayerScripts
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local player = Players.LocalPlayer
local function doTeleport(_actionName, inputState, _inputObject)
local character = player.Character
if character and character.Parent and inputState == Enum.UserInputState.Begin then
-- Move the character 10 studs forwards in the direction they're facing
local currentPivot = character:GetPivot()
character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
end
end
ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)
PivotTo
피벗이 지금 지정된 PVInstance 에 위치하도록 모든 하위 요소 PVInstances 와 함께 변환하여 피벗이 지금 지정된 CFrame 에 위치합니다.이것은 스크립팅을 통해 Models를 이동하는 데 사용해야 하는 주요 기능입니다.
는 필요한 오프셋으로 변환되어 이런 방식으로 이동됩니다.Models는 필요한 오프셋으로 변환되어 이런 방식으로 이동됩니다. their Model.WorldPivot are moved in this way by having their transformed by the necessary offset.
효율성을 위해 Object.Changed 이벤트는 이 방식으로 이동된 Position 및 Orientation 의 BaseParts 를 발사하지 않으며, 오직 CFrame 에서만 발사됩니다.
에서 에 내려오는 부품과 모델의 오프셋이 캐시되어 모델에 대한 후속 호출이 모델을 구성하는 부품 간의 부동 소수점 드리프트를 축적하지 않습니다.When calling on , the offsets of the descendant parts and models are cached, such that subsequent calls to on the same model do not accumulate floating point drift between the parts making up the model.
Models 및 BaseParts 는 모두 PVInstances ("위치 속도 인스턴스")이며, 따라서 둘 다 이 기능이 있습니다.
매개 변수
피벗이 이동된 후에 동일해야 하는 CFrame 입니다.The PVInstance that the pivot should equal after moving it.
반환
코드 샘플
-- This code should be placed in a LocalScript under StarterPlayerScripts
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
local player = Players.LocalPlayer
local function doTeleport(_actionName, inputState, _inputObject)
local character = player.Character
if character and character.Parent and inputState == Enum.UserInputState.Begin then
-- Move the character 10 studs forwards in the direction they're facing
local currentPivot = character:GetPivot()
character:PivotTo(currentPivot * CFrame.new(0, 0, -10))
end
end
ContextActionService:BindAction("Teleport", doTeleport, true, Enum.KeyCode.F)