SegmentShape2D
A zero-thickness segment between two local points.
SegmentShape2D defines one segment with endpoints A and B. Defaults are A=(0,0), B=(0,10). B is the second endpoint coordinate, not an offset from A. For example, A=(-10,0), B=(10,0) defines a horizontal segment of length 20. Use finite distinct endpoints.
The physics shape has no thickness. A thick diagnostic stroke does not turn it into a rectangle: in the check, a radius-1 circle overlapped the line at center (0,0.5), but not at (0,2). For a wall with thickness, use RectangleShape2D or a convex polygon.
GetRect() encloses local A and B. A horizontal segment has zero bounds height; a vertical segment has zero width. These are valid results, not loading errors. Use a shape query for collision rather than testing whether the rectangle has area. A/B and SetA/SetB update the same geometry; Changed is emitted only for a new value.
For a collider, assign the resource to Shape on CollisionShape2D, which must be a direct child Entity of CollisionObject2D. Creating a resource alone adds no body to the world. Editing a shared resource affects every user.
Defaults, both setters/getters, notifications, local bounds and direct circle overlaps were checked. Body response, fast movement, image quality and other backends were not tested.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SegmentShape2DConstructor
public SegmentShape2D();Creates a zero-thickness segment from A=(0,0) to B=(0,10). Creates neither a body nor an automatically visible line.
Properties2
AProperty
public Vector2 A { get; set; }First endpoint in local coordinates, initially (0,0). B holds the second endpoint; this is not the Entity’s world position. Use finite distinct endpoints. A change updates the physics shape and emits Changed; repeating a value does not.
BProperty
public Vector2 B { get; set; }Second endpoint in local coordinates, initially (0,10). A point, not a rectangle size or an offset from A. Use a finite value distinct from A. A change emits Changed; repeating a value does not.
Methods4
GetAVector2
public Vector2 GetA();Stored local coordinate of the first endpoint.
Vector2Stored local coordinate of the first endpoint.
GetBVector2
public Vector2 GetB();Stored local coordinate of the second endpoint, not an offset from A.
Vector2Stored local coordinate of the second endpoint, not an offset from A.
SetAvoid
public void SetA(Vector2 a);First endpoint in local coordinates, initially (0,0). B holds the second endpoint; this is not the Entity’s world position. Use finite distinct endpoints. A change updates the physics shape and emits Changed; repeating a value does not.
| Name | Type | Default |
|---|---|---|
a | Vector2 | — |
aNew local A coordinate; finite and distinct from B.
SetBvoid
public void SetB(Vector2 b);Second endpoint in local coordinates, initially (0,10). A point, not a rectangle size or an offset from A. Use a finite value distinct from A. A change emits Changed; repeating a value does not.
| Name | Type | Default |
|---|---|---|
b | Vector2 | — |
bNew local B coordinate; finite and distinct from A, not an offset from it.