踪迹 对象用于创建两个附件之间的踪迹效果。当附件在空间移动时,在其定义的平面上绘制了纹理。这通常用于创建效果,可以视觉化像追踪轨道、脚印、轮胎轨道和类似效果的运动。
请参阅踪迹获取更多信息。
代码示例
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.
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
概要
属性
与 Attachment1 一起,决定踪迹将在哪里开始绘制其段落。
与 Attachment0 一起,决定踪迹将在哪里开始绘制其段落。
当 LightInfluence 小于 1 时,将发射到踪迹的光放大。
在其生命周期内的踪迹的颜色。
决定是否绘制踪迹。
决定踪迹是否始终面向相镜头,无论其方向。
决定每个踪迹段的持续时间,以秒为单位。
决定颜色踪迹的颜色与它后面的颜色融合到什么程度。
决定踪迹受环境照明影响的程度。
设置踪轨迹最大长度。
设置踪轨迹最小长度。
要显示在轨迹迹上的纹理内容ID。
设置踪轨迹的纹理长度,取决于 TextureMode。
决定 Texture 缩放、重复和跟随踪轨迹附件的方式。
设置踪轨迹的段落透明度在其 Lifetime 上。
在其生命周期内扩展踪迹的宽度。
属性
Attachment0
Attachment1
Brightness
Color
代码示例
local TweenService = game:GetService("TweenService")
-- 创建一个父部件
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
-- 在零件上创建附件
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
-- 创建带颜色渐变的新踪迹
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
-- 中途部分显示踪迹
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
FaceCamera
Lifetime
LightEmission
LightInfluence
LocalTransparencyModifier
MaxLength
MinLength
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