Trail

非推奨を表示

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

トレイルオブジェクトは、2つのアタッチメント間のトレイル効果を作成するために使用されます。アタッチメントがスペースを移動するにつれて、テクスチャが定義されたプレーンに描かれます。これは、プロジェクトiles、足跡、車輪、その他のエフェクトなど、動きをビジュアル化するトレイル効果を作成するために使用されます。

詳しくは、トレイルを参照してください。

コードサンプル

This example demos the functionality of Trails by creating a BasePart to be the parent of the trail. Two Attachments are then parented to the part. The positions of these two attachments (more importantly the distance between them) determines where the trail is drawn as the part moves.

For these attachments to create a trail as described, a new Trail is parented to the part and its Attachment0 and Attachment1 are parented to attachment0 and attachment1 respectively. Finally, TweenService is used to move the part back and forth, showing how the trail is drawn as the part (and its attachments) move.

Creating a Part with a Basic Trail

local TweenService = game:GetService("TweenService")
-- Create a parent part
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(4, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- Create attachments on part
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-2, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(2, 0, 0)
attachment1.Parent = part
-- Create a new trail
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
trail.Parent = part
-- Tween part to display trail
local dir = 15
while true do
dir *= -1
local goal = {Position = part.Position + Vector3.new(0, 0, dir)}
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

概要

プロパティ

  • 並列読み取り

    Class.Trail.Attach1|Attach1 と一緒に、トレイルのセグメントを描画する場所を決定します。

  • 並列読み取り

    Class.Trail.Attach0|Attach0 と一緒に、トレイルのセグメントを描画する場所を決定します。

  • 並列読み取り

    Class.Trail.LightInfluence|LightInfluence が 1 未満のとき、トレイルから発射されるライトのサイズをスケールします。

  • 並列読み取り

    トレイルの色は、そのライフタイムにわたって変更されません。

  • 並列読み取り

    トレイルが描かれるかどかを決定します。

  • 並列読み取り

    トレイルが常にカメラに向かっているかどうかを決定します。

  • 並列読み取り

    トレイル内の各セグメントの長さを、秒単位で決めます。

  • 並列読み取り

    トレイルの色が背後の色とどの程度混ざるかを決定します。

  • 並列読み取り

    環境の照明によってトレイルの影響度を決めます。

  • 非表示
    複製されていません
    並列読み取り
  • 並列読み取り

    トレイルの最大長度を設定します。

  • 並列読み取り

    トレイルの最小長度を設定します。

  • Texture:ContentId
    並列読み取り

    トレイルに表示するテクスチャの ID コンテンツ。

  • 並列読み取り

    Class.Trail.TextureMode|TextureMode により、トレイルのテクスチャの長さが設定されます。

  • 並列読み取り

    Class.Trail.Texture|Texture がトレイルのアタッチメントと共にスケール、重複、および移動する方法を決定します。

  • 並列読み取り

    トレイルのセグメントの透明度を Lifetime で設定します。

  • 並列読み取り

    トレイルの幅を、寿命全体にわたって拡大/縮小する。

プロパティ

Attachment0

並列読み取り

Class.Trail は、 Attach0 および Attachment1 の位置でセグメントを描画し始めます。1> Class.

トレイルが描画されている間、トレイルのアタッチメントを変更すると、トレイルがすでに描画したセグメントをすべて削除します。

Attachment1

並列読み取り

Class.Trail は、Attachment0Attach1 の位置でセグメントを描画し始めます。1>Class.Trail

トレイルが描画されている間、トレイルのアタッチメントを変更すると、トレイルがすでに描画したセグメントをすべて削除します。

Brightness

並列読み取り

Class.Trail.LightInfluence|LightInfluence が 1 未満のとき、トレイルから発射されるライトのサイズをスケールします。このプロパティはデフォルトで 1 です。範囲 0 から 10000 の間の任意の値に設定できます。Class.Trail.LightInfluence

並列読み取り

トレイルの色をライフタイムで決定します。Class.Trail.Texture|Texture が設定する定されている場合、この色はテクスチャに色をつけます。

このプロパティは、ColorSequence で、色をトレイルの長さに応じて構成できます。トレイルの段の 1 つが描かれた後、すべての古いセグメントが更新され、新しい色と一致するように更新されます。

コードサンプル

This example creates a Trail with a gradient color, meaning that the color at one end of the trail is different than the color at the opposite end, and both colors blend together as they get closer to the middle of the trail.

Creating a Trail with a Color Gradient

local TweenService = game:GetService("TweenService")
-- Create a parent part
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(4, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- Create attachments on part
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-2, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(2, 0, 0)
attachment1.Parent = part
-- Create a new trail with color gradient
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
local color1 = Color3.fromRGB(255, 0, 0)
local color2 = Color3.fromRGB(0, 0, 255)
trail.Color = ColorSequence.new(color1, color2)
trail.Parent = part
-- Tween part to display trail
local dir = 15
while true do
dir *= -1
local goal = {Position = part.Position + Vector3.new(0, 0, dir)}
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

Enabled

並列読み取り

このプロパティは、トレイルが描かれるかどうかを決定します。

トレイルが描画されている間、<a href="/reference/engine/datatypes">データタイプ</a> を設定している場合、新しいセグメントは描画されませんが、既存のセグメントは <a href="/reference/engine/datatypes">データタイプ</a> で自然にクリーンアップします。<a href="/reference/engine/datatypes">データタイプ</a>

FaceCamera

並列読み取り

Class.Trail は、3D 空間に存在する 2D プロジェクションで、 すべての角度から見えない ことが意味します。true プロパティ、1> true1> を設定すると、4> Class.Workspace.CurrentCamera|CurrentCamera4> のすべての方向に対し

このプロパティを変更すると、すべての既存のおよび将来のトレイルセグメントに影響します。

Lifetime

並列読み取り

有効期限 プロパティは、トレイルの各セグメントがどれくらい長く持続するかを決定します、秒単位の時間待ち、それから消えます。デフォルトは 2 秒ですが、 0.01 から 20 の間で任意の場所で設定できます。

このエフェクトの ColorTransparency プロパティは、各セグメントを描画する方法を決定するために使用されます。両方のプロパティは、Class.Trail.Color と 2>Class.Trail.Transparency2> の値をそれぞれ特定のキ

トレイルの有効期限が変更されると、既存のセグメントはすぐに新しい有効期限を持っているかのように動作し、長くトレイルが存在すると、すぐに削除されます。

LightEmission

並列読み取り

トレイルの色が背後の色とどの程度混ざっているかを決定します。0から1の範囲で設定する必要があります。0の値は、通常のブレンドモードを使用し、1の値は、追加のブレンドモードを使用します。

このプロパティは、LightInfluence と混同してはなりません。これは、トレイルが環境光にどのように影響されるかを決定します。

このプロパティを変更すると、すべての既存および将来のトレイルのセグメントに影響します。

このプロパティは、 トレイルを環境に照明する ため、トレイルをライトにすることはありません。

LightInfluence

並列読み取り

0 から 1 の間にクランプされた環境の照明の影響度を決めます。0 のとき、トレイルは環境の照明に影響を受けません。1 のとき、トレイルは照明の影響を受けます。BasePart が影響を受けると、トレイルは影響を受けません。

このプロパティを変更すると、すべての既存および将来のトレイルのセグメントに影響します。

また、LightEmission を参照して、トレイルの色が背後の色とどの程度混ざっているかを指定します。

LocalTransparencyModifier

非表示
複製されていません
並列読み取り

MaxLength

並列読み取り

このプロパティは、トレイルの最大長度をスタッドで決定します。デフォルトは 0 です。これは、トレイルに最大長度がないことを意味し、トレイルのセグメントが Lifetime で期限切れになります。

このプロパティは、MinLength プロパティと一緒に使用されることができます。これは、トレイルが描画される前に最小限の長さを決定します。

MinLength

並列読み取り

このプロパティは、トレイルの最小長度をスタッドで決定します。トレイルの 1つのアタッチメントが、この値以下に移動しない場合、新しいトレイルのセグメントは作成されず、現在のセグメントの端点は、アタッチメントの現在の位置に移動されます。

このプロパティを変更すると、新しいセグメントのみが影響を受けます; 既存のセグメントは、現在の長さを維持します。

このプロパティは、MaxLength プロパティと一緒に使用することができます。これは、最古のセグメントが削除される前に最大トレイルの長さを決定します。

Texture

ContentId
並列読み取り

トレイルに表示するテクスチャのコンテンツID。このプロパティを設設定するしないと、トレイルは円形の飛行機として表示されます。これは、テクスチャが無効なコンテンツID または関連する画像がロードされていない場合にも発生します。

テクスチャの外観は、ColorTransparency などの他のトレイルプロパティによってさらに変更できます。

テクスチャのスケーリングは、Attachment0Attachment1 、および TextureMode 、 1>Class.Trail.TextureLength|TextureLength1> および 4>Class.Trail.

コードサンプル

This example adds a paw prints texture to a trail object. In order for the paw prints to remain "stamped" in place after rendering, TextureMode is set to Enum.TextureMode.Static.

Creating a Trail with a Paw Print Texture

local TweenService = game:GetService("TweenService")
-- Create a parent part
local part = Instance.new("Part")
part.Material = Enum.Material.SmoothPlastic
part.Size = Vector3.new(2, 1, 2)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Parent = workspace
-- Create attachments on part
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Position = Vector3.new(-1, 0, 0)
attachment0.Parent = part
local attachment1 = Instance.new("Attachment")
attachment1.Name = "Attachment1"
attachment1.Position = Vector3.new(1, 0, 0)
attachment1.Parent = part
-- Create a new trail with color gradient
local trail = Instance.new("Trail")
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
trail.Texture = "rbxassetid://16178262222"
trail.TextureMode = Enum.TextureMode.Static
trail.TextureLength = 2
trail.Parent = part
-- Tween part to display trail
local dir = 15
while true do
dir *= -1
local goal = {Position = part.Position + Vector3.new(0, 0, dir)}
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(4)
end

TextureLength

並列読み取り

Class.Trail.TextureMode|TextureMode により、トレイルのテクスチャの長さが設定されます。このプロパティを変更すると、すべての既存および将来のトレイルセグメントに影響します。

TextureMode

並列読み取り

このプロパティは、TextureLength と共に、トレイルの Texture がどのようにスケール、Class.Trail.Texture|Texture のアタッチメントと共に移動するかを決定します。このプロパティを変更すると、すべての既存のおよび将来のトレイルセグメントに影響します。

スケールと繰り返し

Class.Trail.TextureLength|TextureLength プロパティは、Enum.TextureMode.WrapEnum.TextureMode.Static または 1>枚数.TextureMode.Static1> に設定されているとき、テクスチャの長さがトレイルの長度に反復しています。

TextureMode diagram with Wrap mode

テクスチャモード が Enum.TextureMode.Stretch に設定されると、テクスチャはトレイル全体の長度にわたって TextureLength を繰り返します。

TextureMode diagram with Stretch mode

移動

Texturモード プロパティは、トレイルのテクスチャの 移動 にも影響します:

  • енью.TextureMode.Stretch に設定されている場合、テクスチャはトレイルの寿命に基づいて伸び、トレイルのアタッチメントが動くのを停止すると、内側に縮小されます。

  • enum.texturemode.Wrap に設定されている場合、テクスチャはトレイルの長さに応じてタイル化されますが、テクスチャはアタッチメントに対して相対的に固定されます。

  • Entity.TextureMode.Static に設定されている場合、テクスチャは取り付けられるように移動し、寿命が切れるまでその場所に残ります。この設定は、「Enum.TextureMode.Static」で表示されるトレイルテクスチャの場合、または「スタンプ」で表示されるトレイルテクスチャの場合に理想的です。この設定は、「印刷」で表示さ

Transparency

並列読み取り

トレイルのセグメントの透明度を Lifetime で設定します。この値は、NumberSequence で、静的値か変更可能です。

WidthScale

並列読み取り

このプロパティは、NumberSequenceで、トレイルの幅をコーストライフの全体にわたってスケールします。値は 0 から 1 の間に変更され、トレイルのアタッチメントの間の距離を掛け算します。たとえば、トレイルのアタッチメントが

方法

Clear

void

このメソッドは、すべてのトレイルのセグメントをすぐにクリアし、長い寿命のトレイルや特定のアクションによりトレイルを削除する必操作がある場合に便利です。

このメソッドを呼び出すと、既存のセグメントにのみ影響します。現在のトレイルセグメントをクリアするためには、トレイルの Class.Trail.Enabled|Enabled プロパティを Enabled 一時的に false に変更し、トレイルの 2>Class.Trail.Enabled|Enabled2> プロパティを 5>5> 一緒に切り替えます。


戻り値

void

イベント