terminalCode Example
BeamEffect — laser and energy beams between two points
BeamEffect — Laser and Energy Beams
BeamEffect renders a beam between two points in the world. Use it for lasers, electricity, tractor beams, or any line-based visual effect.Basic Beam Between Two Points
CSHARP
var go = Scene.CreateObject();
go.Name = "Laser";
go.WorldPosition = emitterPosition;
var beam = go.Components.Create<BeamEffect>();
beam.TargetPosition = targetPosition; // world-space end point
beam.Scale = 2f; // beam width
beam.Looped = true;Beam Tracking a Target GameObject
CSHARP
public sealed class TractorBeam : Component
{
[Property] public GameObject Target { get; set; }
BeamEffect _beam;
protected override void OnStart()
{
_beam = Components.Create<BeamEffect>();
_beam.Scale = 3f;
_beam.Looped = true;
}
protected override void OnUpdate()
{
if ( Target.IsValid() )
_beam.TargetPosition = Target.WorldPosition;
}
}Burst Beams (Multiple Per Second)
CSHARP
var beam = go.Components.Create<BeamEffect>();
beam.BeamsPerSecond = 10f; // fire 10 beams per second
beam.MaxBeams = 5; // max simultaneous beams alive
beam.Looped = false; // each beam is a one-shotAttaching to a Target GO
When TargetObject is set the beam end tracks the GO automatically:
CSHARP
beam.TargetObject = enemyGameObject;
beam.Scale = 1.5f;Toggling On/Off
CSHARP
// Enable/disable the component to show/hide the beam
_beam.Enabled = isFiring;Tips
- Pair with a PointLight at the emitter and target for a convincing glow.
- Use BeamsPerSecond + short lifetime for electric arc effects.
- For a solid continuous beam, set Looped = true and MaxBeams = 1.
Was this helpful?