Trail
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
วัตถุ เส้นทาง ใช้เพื่อสร้างเอฟเฟกต์เส้นทางระหว่างสองแนบเมื่อสิ่งที่แนบมาเคลื่อนที่ผ่านอวกาศแล้ว เทกเจอร์จะถูกวาดบนแผนการที่กำหนดไว้สิ่งนี้มักใช้เพื่อสร้างเอฟเฟกต์ที่แสดงการเคลื่อนไหวเช่นเส้นทางติดตามเบื้องหลังกระสุนปืน รอยเท้า เส้นทางยาง และเอฟเฟกต์ที่คล้ายกัน
ดู เส้นทาง สำหรับข้อมูลเพิ่มเติม
ตัวอย่างโค้ด
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