Skip to content

BoxCollider

namespace Griff.Scenes;
public sealed class BoxCollider : Collider

A box for collisions, centered on the entity (plus Offset) and scaled by its transform. It stays upright whatever the entity’s rotation, unless its BodyRotates: then it turns with the entity. Without a Body the box is static: walls, floors, platforms.

This is a component: its saved properties are on its component page.

public override string? IgnoreLayers { get; set; }
public override bool IsTrigger { get; set; }
public override string? Layer { get; set; }
public override Vector2 Offset { get; set; }
public bool OneWay { get; set; }

Only blocks bodies landing on top: jump up through it from below, stand on it from above.

public Vector2 Size { get; set; }

Width and height, in world units before the transform’s scale.

public override Box WorldBounds { get; }
public Box WorldBox { get; }

The box it covers in the world, from its entity’s position and scale. One that Turns is the box round it as it’s turned (see WorldShape for the turned box itself).

public ValueTuple<Vector2, Vector2, Vector2, Vector2> WorldCorners { get; }

Its four corners in the world, anticlockwise from the bottom left (as it’s turned, if it Turns).

public ValueTuple<Vector2, Vector2, Vector2> WorldShape { get; }

The box in the world as it is: its middle, half its width and height, and which way its own X axis points (a unit vector, (1, 0) unless it Turns; its Y axis is that turned a quarter anticlockwise).

public override bool Contains(Vector2 point)