PVInstance
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
A PVInstance ("Instancja prędkości pozycji") to abstrakcyjna klasa, która nie może zostać utworzona.Jest to podstawa dla wszystkich obiektów, które mają fizyczną lokalizację na świecie, w szczególności BaseParts i Models.
Podsumowanie
Właściwości
Metody
Otrzymuje pivot z PVInstance .
Przekształca PVInstance wraz z całym jego potomkiem PVInstances tak, że osie zostaną teraz umieszczone w określonym CFrame .
Właściwości
Metody
GetPivot
Funkcja ta otrzymuje pivot PVInstance . Często jest używana z PVInstance:PivotTo() , aby przesunąć model.
Models i BaseParts są oba PVInstances ("Instancje prędkości pozycji") i oba mają tę funkcję.
Zwroty
Przykłady kodu
This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with PVInstance:GetPivot() and calling PVInstance|PivotTo to move the character forwards.
-- 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
Przekształca PVInstance wraz z całym jego potomkiem PVInstances tak, że osie zostaną teraz umieszczone w określonym CFrame .To jest główna funkcja, którą należy używać do przesuwania Models za pomocą skryptowania.
BaseParts są przenoszone w ten sposób, mając ich CFrame przekształcone przez niezbędny offset.Models są przenoszone w ten sposób, mając ich Model.WorldPivot przekształcone przez niezbędny offset.
Zauważ, że ze względów wydajności, wydarzenia Object.Changed nie są uruchamiane dla Position i Orientation z BaseParts przeniesionymi w ten sposób; są uruchamiane tylko dla CFrame .
Podczas wezwania PivotTo na Models są przechowywane przesunięcia części i modeli potomnych, tak że kolejne wezwania do PivotTo na tym samym modelu nie gromadzą driftingu punktów zwrotnych między częściami składającymi się na model.
Models i BaseParts są oba PVInstances ("Instancje prędkości pozycji") i oba mają tę funkcję.
Parametry
The CFrame że pivot PVInstance powinien być równy po jego przesunięciu.
Zwroty
Przykłady kodu
This code sample is a simple teleport script that moves your character 10 studs forwards in the direction you're currently facing when you press the F key. It does so by getting the current pivot with PVInstance:GetPivot() and calling PVInstance|PivotTo to move the character forwards.
-- 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)