Lớp công cụ
Beam
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Mẫu mã
Tạo một Beam từ con số 0
-- tạo các attachment
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")
-- cha vào địa hình (có thể là một phần thay thế)
att0.Parent = workspace.Terrain
att1.Parent = workspace.Terrain
-- vị trí các attachment
att0.Position = Vector3.new(0, 10, 0)
att1.Position = Vector3.new(0, 10, 10)
-- tạo beam
local beam = Instance.new("Beam")
beam.Attachment0 = att0
beam.Attachment1 = att1
-- thuộc tính hình dáng
beam.Color = ColorSequence.new({ -- một dãy màu chuyển từ trắng sang xanh
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 255, 255)),
})
beam.LightEmission = 1 -- sử dụng hòa trộn cộng
beam.LightInfluence = 0 -- beam không bị ảnh hưởng bởi ánh sáng
beam.Texture = "rbxasset://textures/particles/sparkles_main.dds" -- một kết cấu lấp lánh tích hợp sẵn
beam.TextureMode = Enum.TextureMode.Wrap -- bọc để chiều dài có thể được đặt bằng TextureLength
beam.TextureLength = 1 -- kết cấu lặp lại dài 1 stud
beam.TextureSpeed = 1 -- tốc độ kết cấu chậm
beam.Transparency = NumberSequence.new({ -- beam mờ đi ở cuối
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(0.8, 0),
NumberSequenceKeypoint.new(1, 1),
})
beam.ZOffset = 0 -- render ở vị trí của beam mà không có độ dịch
-- thuộc tính hình dạng
beam.CurveSize0 = 2 -- tạo một beam cong
beam.CurveSize1 = -2 -- tạo một beam cong
beam.FaceCamera = true -- beam có thể nhìn thấy từ mọi góc độ
beam.Segments = 10 -- độ phân giải cong mặc định
beam.Width0 = 0.2 -- bắt đầu nhỏ
beam.Width1 = 2 -- kết thúc lớn
-- cha beam
beam.Enabled = true
beam.Parent = att0Tài Liệu Tham Khảo API
Thuộc Tính
Texture
Beam.Texture:ContentId
ZOffset
Mẫu mã
Các Tia Lớp
-- Tạo các tia
local beam1 = Instance.new("Beam")
beam1.Color = ColorSequence.new(Color3.new(1, 0, 0))
beam1.FaceCamera = true
beam1.Width0 = 3
beam1.Width1 = 3
local beam2 = Instance.new("Beam")
beam2.Color = ColorSequence.new(Color3.new(0, 1, 0))
beam2.FaceCamera = true
beam2.Width0 = 2
beam2.Width1 = 2
local beam3 = Instance.new("Beam")
beam3.Color = ColorSequence.new(Color3.new(0, 0, 1))
beam3.FaceCamera = true
beam3.Width0 = 1
beam3.Width1 = 1
-- Xếp chồng các tia
beam1.ZOffset = 0
beam2.ZOffset = 0.01
beam3.ZOffset = 0.02
-- Tạo các bộ gắn
local attachment0 = Instance.new("Attachment")
attachment0.Position = Vector3.new(0, -10, 0)
attachment0.Parent = workspace.Terrain
local attachment1 = Instance.new("Attachment")
attachment1.Position = Vector3.new(0, 10, 0)
attachment1.Parent = workspace.Terrain
-- Kết nối các tia
beam1.Attachment0 = attachment0
beam1.Attachment1 = attachment1
beam2.Attachment0 = attachment0
beam2.Attachment1 = attachment1
beam3.Attachment0 = attachment0
beam3.Attachment1 = attachment1
-- Gán các tia vào
beam1.Parent = workspace
beam2.Parent = workspace
beam3.Parent = workspacePhương Pháp