PVInstance

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

作成できません
閲覧できません

A PVInstance (「位置速度インスタンス」)は、作成できない抽象クラスです。世界に物理的な場所を持つすべてのオブジェクトの基礎であり、特に BasePartsModels です。

概要

プロパティ

  • 複製されていません
    スクリプト作成できません
    並列読み取り
  • 複製されていません
    スクリプト作成できません
    並列読み取り

方法

プロパティ

Origin

複製されていません
スクリプト作成できません
並列読み取り

Pivot Offset

複製されていません
スクリプト作成できません
並列読み取り

方法

GetPivot

並列書き込み

この機能は、PVInstance のピボットを取得します。これはモデルを移動するために PVInstance:PivotTo() とよく使用されます。

ModelsBaseParts は両方とも 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.

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

()

変換する PVInstance とすべての子孫 PVInstances を通じて、ピボットが現在指定された CFrame に位置します。これは、スクリプトで Models を移動するために使用する主な機スクリプト作成です。

は、必要なオフセットによって変換されて、この方法で移動されます。 は、必要なオフセットによって変換されて、この方法で移動されます。

効率の目的で、Object.Changedイベントは、PositionおよびOrientationBaseParts移動では発射されません;彼らはCFrameのみで発射されます。

を呼び出すと、子孫のパーツとモデルのオフセットがキャッシュされ、同じモデルの後続の呼び出しがモデルを構成するパーツ間の浮動小数点ドリフトを蓄積しないようになります。

ModelsBaseParts は両方とも PVInstances ("位置速度インスタンス")であり、両方ともこの機能があります。

パラメータ

targetCFrame: CFrame

移動後、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.

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)

イベント