RectangleShape2D
Rectangular 2D collision geometry specified by full dimensions.
Size is the full rectangle width and height, initially (20,20). For example, Size=(40,12) produces GetRect()=(-20,-6,40,12): the center is the local origin, extending 20 units left and right. Do not pass half extents. GetRect() excludes the resource user’s position and rotation.
Assign the resource to Shape on a CollisionShape2D inside CollisionObject2D. A shape does not create a body by itself. Use distinct resource instances when two colliders need independent dimensions.
Size and SetSize update the same geometry. Negative components are rejected; use positive finite values for a working shape. Changed is emitted for a change, but not for an identical Size assignment.
Values, local bounds, notifications and direct overlap queries with a circle were checked. This does not establish body movement, friction behavior or rendered appearance.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
RectangleShape2DConstructor
public RectangleShape2D();Creates a rectangle with full Size=(20,20), centered at the local origin. A geometry resource, not an independent physics body.
Properties1
SizeProperty
public Vector2 Size { get; set; }Full width and height, initially (20,20), not half extents. The center is at the local origin. Negative components are rejected; use positive finite components. A change updates the physics shape and emits Changed; repeating a value does not.
Methods2
GetSizeVector2
public Vector2 GetSize();Current full width and height, not half extents.
Vector2Current full width and height, not half extents.
SetSizevoid
public void SetSize(Vector2 size);Full width and height, initially (20,20), not half extents. The center is at the local origin. Negative components are rejected; use positive finite components. A change updates the physics shape and emits Changed; repeating a value does not.
| Name | Type | Default |
|---|---|---|
size | Vector2 | — |
sizeFull width and height in local units; positive finite components.