Manual

Manual

Line

A Line is a ribbon through a list of points: a laser, an aim arc, a rope, a connector between two things, a route on a map. This page covers making one, its points and how to place them in the Scene view, how it looks, and setting its points from code.

Make a line

  • Entity ▸ Effects ▸ Line, or the same item in the Hierarchy's + menu, makes one in 3D: two points a unit apart along X, a fifth of a unit wide, solid white.
  • Entity ▸ Effects ▸ Line 2D makes one drawn flat among sprites, a tenth of a unit wide.
  • Add Component puts one on any entity.

The Scene view marks a Line with line segments.

Line

Its points

Points lists the points, a line each with its X, Y and Z. The + at the right of the row adds a point after the last, as far on as the last piece goes. The × on a line takes that point away, while more than two are left.

FieldWhat it does
PointsWhere the line goes, in order.
LoopGoes on from the last point back to the first: a ring, a fence round a field.
World SpaceThe points stay where they are in the world however the entity moves, for points your code sets each frame. Off, they are in the entity's own space, and move, turn and scale with it as a mesh's points do.

How it looks

A Line looks the way a Trail does, along its points from the first to the last:

FieldWhat it does
WidthHow wide it is, in units, times Width over Line.
Width over LineHow wide it is along its length, from its first point to its last: a constant, a curve, or one picked between two.
Color over LineIts color along its length: a color, a gradient, or one picked between two.
Corner VerticesHow many points go round each corner. 0 cuts the corner.
End Cap VerticesHow many points go round each end. 0 leaves them flat.
AlignmentIn 3D. View: turned to face the camera. Local: lying in its entity's XZ plane, facing its +Y.
Texture ModeStretch: the texture once from the first point to the last. Tile: again and again, once every Tile Length units.
MaterialIn 3D, a material file that draws it in place of its texture and blending.
TextureThe picture it is drawn with: solid white (Solid) until you give it one.
BlendingAlpha, Additive or Opaque, as a Trail's.
FlatDrawn among sprites by a 2D camera, rather than in 3D.
Sorting Layer, Order in LayerFlat: where it is drawn among sprites.

Width over Line and Color over Line are edited with the curve and gradient editors described in Numbers that change: curves and gradients.

Blended Alpha or Additive, where a Line crosses itself its later part is drawn over its earlier. Opaque draws it solid, the nearest part in front wherever it crosses itself or anything else, its texture cut away where less than half opaque. Its corners keep its whole width, are round from whichever side they are seen, and are drawn once, so a see-through Line is as see-through at its corners as along it.

A Line that does not change costs nothing a frame: its mesh is made again only when the Line, its points or its entity change.

Edit Points

Edit Points, the button at the top of the Line's section, places its points in the Scene view.

  • Flat, the points are dots on the entity's XY plane. Drag a dot to move it. Click the line between two points to add one there. Ctrl and a click on a dot deletes it.
  • In 3D, click a dot to pick that point: it gets the Move tool's arrows and squares, which move it as they move an entity, snapped as they are. Click the line between two points to add one there and pick it. Ctrl and a click on a dot deletes it.

A Line always keeps two points at least. Each change is one Ctrl+Z. Escape, the button again, choosing a tool, or picking something else ends editing, and while it is on, the tools' own handles are hidden.

Lines from code

A game's C# sets and reads a Line's points through world.Lines. With World Space ticked, a laser between two things is two points set each frame:

// beam is an entity with a Line whose World Space is ticked.static void Aim(World world, ulong beam, Vector3 muzzle, Vector3 target){    world.Lines.SetPoints(beam, [muzzle, target]);   // every point at once    world.Lines.SetPoint(beam, 1, target);           // or one, by its place    Vector3[] points = world.Lines.Points(beam);     // in the entity's space, or the world's}

SetPoint throws for an index past the last point. Points(entity, span) reads into a span without allocating, and returns how many points there are.

A game's Rust systems take GameLines from abyss_ffi, with points, set_points and set_point.

In the Scripting API