PVInstance

Artık kullanılmayanları göster

*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.

Oluşturulamaz
Gezilemez

Bir PVInstance ("Pozisyon Hızı İstemi") soyut bir sınıftır ve oluşturulamaz.Dünyada fiziksel bir konuma sahip olan tüm nesnelerin temelidir, özellikle BaseParts ve Models.

Özet

Özellikler

Yöntemler

Özellikler

Origin

Çoğaltılmamış
Betiklenemez
Paralel oku

Pivot Offset

Çoğaltılmamış
Betiklenemez
Paralel oku

Yöntemler

GetPivot

Paralel yaz

Bu işlev bir PVInstance 'nin merkezini alır. Bu genellikle bir modeli hareket ettirmek için PVInstance:PivotTo() ile kullanılır.

Models ve BaseParts her ikisi de PVInstances ("Pozisyon Hızı İstisnaları") ve bu nedenle her ikisi de bu işleve sahiptir.


Dönüşler

Kod Örnekleri

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

()

Dönüştürür PVInstance tüm altındaki PVInstances ile birlikte pivotun şimdi belirtilen CFrame 'de yer aldığını, böylece dönüşüm aşağıdaki gibi gerçekleşir:Bu, senaryo aracılığıyla Models taşımak için kullanılması gereken temel işlevdir.

BaseParts , gerekli ofset tarafından dönüştürülerek böyle taşınır CFrame.Models şekilde hareket edilir ve gerekli ofset tarafından dönüştürülürler, böylece Model.WorldPivot dönüştürülürler.

Verimlilik açısından, Object.Changed etkinlikleri Position ve Orientation için atlanmaz; sadece BaseParts için ateşlenirler; yalnızca CFrame için ateşlenirler.

üzerinde çağrıldığında, alt kısımların ve modellerin ofsetleri önbelleğe alınır, böylece aynı modeldeki 'ye yapılan sonraki çağrılar modeli oluşturan parçalar arasındaki yüzde değişimini biriktirmez.

Models ve BaseParts her ikisi de PVInstances ("Pozisyon Hızı İstisnaları") ve bu nedenle her ikisi de bu işleve sahiptir.

Parametreler

targetCFrame: CFrame

Döndürülmesinden sonra eşit olması gereken CFrame döndürme noktası PVInstance .

Varsayılan değer: ""

Dönüşler

()

Kod Örnekleri

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)

Etkinlikler