PVInstance
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
A PVInstance (「位置速度インスタンス」)は、作成できない抽象クラスです。世界に物理的な場所を持つすべてのオブジェクトの基礎であり、特に BaseParts と Models です。
概要
方法
PVInstance のピボットを取得します。
変換する PVInstance とすべての子孫 PVInstances を通じて、ピボットが現在指定された CFrame に位置します。
プロパティ
方法
GetPivot
この機能は、PVInstance のピボットを取得します。これはモデルを移動するために PVInstance:PivotTo() とよく使用されます。
Models と BaseParts は両方とも PVInstances ("位置速度インスタンス")であり、両方ともこの機能があります。
戻り値
コードサンプル
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
変換する PVInstance とすべての子孫 PVInstances を通じて、ピボットが現在指定された CFrame に位置します。これは、スクリプトで Models を移動するために使用する主な機スクリプト作成です。
は、必要なオフセットによって変換されて、この方法で移動されます。 は、必要なオフセットによって変換されて、この方法で移動されます。
効率の目的で、Object.Changedイベントは、PositionおよびOrientationのBaseParts移動では発射されません;彼らはCFrameのみで発射されます。
を呼び出すと、子孫のパーツとモデルのオフセットがキャッシュされ、同じモデルの後続の呼び出しがモデルを構成するパーツ間の浮動小数点ドリフトを蓄積しないようになります。
Models と BaseParts は両方とも PVInstances ("位置速度インスタンス")であり、両方ともこの機能があります。
パラメータ
移動後、CFrame ピボットが等しくなる必要がある PVInstance 。
戻り値
コードサンプル
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)