PVInstance

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile
Non Navigabile

Un A PVInstance ("Position Velocity Instance") è una classe astratta che non può essere creata.È la base per tutti gli oggetti che hanno una posizione fisica nel Mondo, in particolare BaseParts e Models.

Sommario

Proprietà

Metodi

Proprietà

Origin

Non Replicato
Non programmabile
Lettura Parallela

Pivot Offset

Non Replicato
Non programmabile
Lettura Parallela

Metodi

GetPivot

Scrivi Parallelo

Questa funzione ottiene il punto focale di un PVInstance . Questo viene spesso utilizzato con PVInstance:PivotTo() per spostare un modello.

Models e BaseParts sono entrambi PVInstances ("Istanti di velocità di posizione") e quindi entrambi hanno questa funzione.


Restituzioni

Campioni di codice

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.

Simple Character Teleportation

-- 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

()

Trasforma il PVInstance insieme a tutti i suoi discendenti PVInstances in modo che il punto di rotazione sia ora situato all'interno del CFrame specificato.Questa è la funzione principale che dovrebbe essere utilizzata per spostare Models via scripting.

BaseParts sono spostati in questo modo trasformando il loro CFrame con l'dislocamentonecessario.Modelsvengono spostati in questo modo trasformando il loro Model.WorldPivot con l'dislocamentonecessario.

Si noti che per scopi di efficienza, gli eventi Object.Changed non vengono sparati per Position e Orientation di BaseParts spostati in questo modo; vengono sparati solo per CFrame .

Quando si chiama PivotTo su Models, gli offset delle parti discendenti e dei modelli vengono memorizzati in cache, in modo che le successive chiamate a PivotTo su lo stesso modello non accumulino il drift di precisione galleggiante tra le parti che compongono il modello.

Models e BaseParts sono entrambi PVInstances ("Istanti di velocità di posizione") e quindi entrambi hanno questa funzione.

Parametri

targetCFrame: CFrame

Il CFrame che il PVInstance asse dovrebbe essere uguale dopo averlo spostato.

Valore predefinito: ""

Restituzioni

()

Campioni di codice

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.

Simple Character Teleportation

-- 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)

Eventi