Skip to main content

Transform

Namespace: MonineEngine.Core

Defines position, rotation, and scale for all entities. This component is required by all entities, and must not be removed or added manually.

public class Transform : Component

Inheritance ObjectComponentTransform
Attributes NullableContextAttribute, NullableAttribute

Fields

Position

Gets or sets the position of the Transform, relative to the upper-left corner of the window. Affects all children and components.

public Vector2 Position;

Rotation

The rotation of the Transform in degrees, with 0 being straight up, moving clockwise. Affects all children and components.

public float Rotation;

Scale

The scale of the Transform. Affects all children and components.

public Vector2 Scale;

Properties

WorldPosition

Gets or sets the position of this Transform in world space.

public Vector2 WorldPosition { get; set; }

Property Value

Vector2

WorldRotation

Gets or sets the rotation of this Transform in world spacec.

public float WorldRotation { get; set; }

Property Value

Single

Parent

Retrieves the Transform of the Entity that parents the Entity this Transform is attached to.

public Transform Parent { get; }

Property Value

Transform

Remarks:

If the parent Entity does not have a parent, this instead returns the Entity this component is attached to.

The angle to the right of this Transform.

public Vector2 Right { get; }

Property Value

Vector2

Left

The angle to the left of this Transform.

public Vector2 Left { get; }

Property Value

Vector2

Up

The angle to the top of this Transform.

public Vector2 Up { get; }

Property Value

Vector2

Down

The angle to the bottom of this Transform.

public Vector2 Down { get; }

Property Value

Vector2

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

Transform()

public Transform()

Methods

GetMatrix()

Retrieves the transform of the Transform in local space as a .

public Matrix GetMatrix()

Returns

Matrix
A Matrix containing information with the scale, rotation, and position of the Entity in local space.

GetWorldMatrix()

Retrieves the transform of the Transform in world space as a .

public Matrix GetWorldMatrix()

Returns

Matrix
A Matrix containing information with the scale, rotation, and position of the Entity in world space.

LookAt(Vector2)

Sets the rotation of this Transform to look at the specified position.

public void LookAt(Vector2 target)

Parameters

target Vector2
The target position to look at.

LookAt(Transform)

Sets the rotation of this Transform to look at the specified Transform.

public void LookAt(Transform target)

Parameters

target Transform
The target Transform to look at.

DistanceTo(Transform)

Calculates the distance between this Transform and the specified Transform.

public float DistanceTo(Transform other)

Parameters

other Transform
The other Transform.

Returns

Single
The distance between this Transform and the specified Transform in pixels.

DistanceTo(Vector2)

Calculates the distance between this Transform and the specified position.

public float DistanceTo(Vector2 position)

Parameters

position Vector2
The other position.

Returns

Single
The distance between this Transform and the specified position in pixels.

DistanceToSquared(Transform)

Calculates the squared distance between this Transform and the specified Transform.

public float DistanceToSquared(Transform other)

Parameters

other Transform
The other Transform.

Returns

Single
The squared distance between this Transform and the specified Transform in pixels.

DistanceToSquared(Vector2)

Calculates the squared distance between this Transform and the specified position.

public float DistanceToSquared(Vector2 position)

Parameters

position Vector2
The other position.

Returns

Single
The squared distance between this Transform and the specified position in pixels.