코드 샘플
처음부터 빔 만들기
-- 첨부 파일 생성
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")
-- 지형에 부모 설정 (대신 파트가 될 수 있음)
att0.Parent = workspace.Terrain
att1.Parent = workspace.Terrain
-- 첨부 파일 위치 설정
att0.Position = Vector3.new(0, 10, 0)
att1.Position = Vector3.new(0, 10, 10)
-- 빔 생성
local beam = Instance.new("Beam")
beam.Attachment0 = att0
beam.Attachment1 = att1
-- 외관 속성
beam.Color = ColorSequence.new({ -- 흰색에서 파란색으로 변화하는 색상 시퀀스
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 255, 255)),
})
beam.LightEmission = 1 -- 덧셈 블렌딩 사용
beam.LightInfluence = 0 -- 빛의 영향을 받지 않는 빔
beam.Texture = "rbxasset://textures/particles/sparkles_main.dds" -- 내장 스파클 텍스처
beam.TextureMode = Enum.TextureMode.Wrap -- 길이를 TextureLength로 설정할 수 있도록 랩핑
beam.TextureLength = 1 -- 반복하는 텍스처는 1 스터드 길이
beam.TextureSpeed = 1 -- 느린 텍스처 속도
beam.Transparency = NumberSequence.new({ -- 빔이 끝에서 사라짐
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(0.8, 0),
NumberSequenceKeypoint.new(1, 1),
})
beam.ZOffset = 0 -- 오프셋 없이 빔 위치에서 렌더링
-- 형태 속성
beam.CurveSize0 = 2 -- 곡선 빔 생성
beam.CurveSize1 = -2 -- 곡선 빔 생성
beam.FaceCamera = true -- 모든 각도에서 보이는 빔
beam.Segments = 10 -- 기본 곡선 해상도
beam.Width0 = 0.2 -- 작게 시작
beam.Width1 = 2 -- 크게 끝남
-- 빔 부모 설정
beam.Enabled = true
beam.Parent = att0API 참조
속성
Texture
Beam.Texture:ContentId
ZOffset
코드 샘플
레이어링 빔
-- 빔 생성
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
-- 빔 레이어링
beam1.ZOffset = 0
beam2.ZOffset = 0.01
beam3.ZOffset = 0.02
-- 첨부물 생성
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
-- 빔 연결
beam1.Attachment0 = attachment0
beam1.Attachment1 = attachment1
beam2.Attachment0 = attachment0
beam2.Attachment1 = attachment1
beam3.Attachment0 = attachment0
beam3.Attachment1 = attachment1
-- 빔 부모 설정
beam1.Parent = workspace
beam2.Parent = workspace
beam3.Parent = workspace메서드