Skip to main content

Collider

Namespace: MonineEngine.Core

Base class for all collider components.

public abstract class Collider : Component

Inheritance ObjectComponentCollider
Attributes NullableContextAttribute, NullableAttribute

Fields

Offset

Gets or sets the offset between the Entity position and the center of the Collider position.

public Vector2 Offset;

IsTrigger

Gets or sets if this Collider is a trigger collider.

public bool IsTrigger;

Properties

Enabled

Gets or sets a value representing if the Component is enabled or not. Defaults to true.
When false, Update and Draw will not be called.

public bool Enabled { get; set; }

Property Value

Boolean

Entity

Gets the Entity this component is attached to.

public Entity Entity { get; internal set; }

Property Value

Entity

Parent

Basically just a shortcut of Entity.Parent.

public Entity Parent { get; }

Property Value

Entity

Transform

Gets the transform of the Component.Entity this component is attached to.

public Transform Transform { get; }

Property Value

Transform

Camera

public Camera2D Camera { get; }

Property Value

Camera2D

Constructors

Collider()

protected Collider()

Methods

Initialize()

public void Initialize()

OnEnabled()

protected void OnEnabled()

OnDisabled()

protected void OnDisabled()

GetBounds()

Gets the bounds of this collider as a .

public abstract Rectangle GetBounds()

Returns

Rectangle
A Rectangle representing the bounds of the collider in world space.

Intersects(Collider)

Determines if this Collider intersects with another Collider.

public abstract bool Intersects(Collider other)

Parameters

other Collider
The other Collider.

Returns

Boolean
If this Collider and the other Collider intersect, true; otherwise, false.

Events

OnCollisionEnter

A callback called when this Collider collides with another collider.

public event Action<CollisionEventArgs> OnCollisionEnter;

OnCollisionStay

A callback called every frame while this Collider is colliding with another collider.

public event Action<CollisionEventArgs> OnCollisionStay;

OnCollisionExit

A callback called when this Collider stops colliding with another collider.

public event Action<CollisionEventArgs> OnCollisionExit;

OnTriggerEnter

A callback called when this Collider collides with another collider, if Collider.IsTrigger is enabled.

public event Action<CollisionEventArgs> OnTriggerEnter;

OnTriggerStay

A callback called every frame while this Collider is colliding with another collider, if Collider.IsTrigger is enabled.

public event Action<CollisionEventArgs> OnTriggerStay;

OnTriggerExit

A callback called when this Collider stops colliding with another collider, if Collider.IsTrigger is enabled.

public event Action<CollisionEventArgs> OnTriggerExit;