Classe de moteur
Beam
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Échantillons de code
Créer un faisceau à partir de zéro
-- créer des attachements
local att0 = Instance.new("Attachment")
local att1 = Instance.new("Attachment")
-- parenté au terrain (peut être une pièce à la place)
att0.Parent = workspace.Terrain
att1.Parent = workspace.Terrain
-- positionner les attachements
att0.Position = Vector3.new(0, 10, 0)
att1.Position = Vector3.new(0, 10, 10)
-- créer le faisceau
local beam = Instance.new("Beam")
beam.Attachment0 = att0
beam.Attachment1 = att1
-- propriétés d'apparence
beam.Color = ColorSequence.new({ -- une séquence de couleur passant du blanc au bleu
ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 255, 255)),
})
beam.LightEmission = 1 -- utiliser le mélange additif
beam.LightInfluence = 0 -- le faisceau n'est pas influencé par la lumière
beam.Texture = "rbxasset://textures/particles/sparkles_main.dds" -- une texture de scintillement intégrée
beam.TextureMode = Enum.TextureMode.Wrap -- emballage pour que la longueur puisse être définie par TextureLength
beam.TextureLength = 1 -- la texture répétée mesure 1 stud de long
beam.TextureSpeed = 1 -- vitesse de texture lente
beam.Transparency = NumberSequence.new({ -- le faisceau disparaît à la fin
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(0.8, 0),
NumberSequenceKeypoint.new(1, 1),
})
beam.ZOffset = 0 -- render à la position du faisceau sans décalage
-- propriétés de forme
beam.CurveSize0 = 2 -- créer un faisceau courbé
beam.CurveSize1 = -2 -- créer un faisceau courbé
beam.FaceCamera = true -- le faisceau est visible sous tous les angles
beam.Segments = 10 -- résolution de courbe par défaut
beam.Width0 = 0.2 -- commence petit
beam.Width1 = 2 -- se termine grand
-- parent du faisceau
beam.Enabled = true
beam.Parent = att0Référence API
Propriétés
Texture
Beam.Texture:ContentId
ZOffset
Échantillons de code
Couches de Faisceaux
-- Créer des faisceaux
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
-- Superposer des faisceaux
beam1.ZOffset = 0
beam2.ZOffset = 0.01
beam3.ZOffset = 0.02
-- Créer des attaches
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
-- Connecter les faisceaux
beam1.Attachment0 = attachment0
beam1.Attachment1 = attachment1
beam2.Attachment0 = attachment0
beam2.Attachment1 = attachment1
beam3.Attachment0 = attachment0
beam3.Attachment1 = attachment1
-- Parent des faisceaux
beam1.Parent = workspace
beam2.Parent = workspace
beam3.Parent = workspaceMéthodes