Body
Declaration
public class tainicom.Aether.Physics2D.Dynamics.Body
Constructors
Body
void Body()
Properties
World
Get the parent World of this body. This is null if the body is not attached.
World World { get }
IslandIndex
int IslandIndex { get }
Remarks: Deprecated in version 1.6
Revolutions
Gets the total number revolutions the body has made.
float Revolutions { get }
Value: The revolutions.
BodyType
Gets or sets the body type. Warning: This property is readonly during callbacks.
BodyType BodyType { get set }
Value: The type of body.
LinearVelocity
Get or sets the linear velocity of the center of mass.
Vector2 LinearVelocity { get set }
Value: The linear velocity.
AngularVelocity
Gets or sets the angular velocity. Radians/second.
float AngularVelocity { get set }
Value: The angular velocity.
LinearDamping
Gets or sets the linear damping.
float LinearDamping { get set }
Value: The linear damping.
AngularDamping
Gets or sets the angular damping.
float AngularDamping { get set }
Value: The angular damping.
IsBullet
Gets or sets a value indicating whether this body should be included in the CCD solver.
bool IsBullet { get set }
Value: true if this instance is included in CCD; otherwise, false.
SleepingAllowed
You can disable sleeping on this body. If you disable sleeping, the body will be woken.
bool SleepingAllowed { get set }
Value: true if sleeping is allowed; otherwise, false.
Awake
Set the sleep state of the body. A sleeping body has very low CPU cost.
bool Awake { get set }
Value: true if awake; otherwise, false.
Enabled
Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a b2World object and remains in the body list. Warning: This property is readonly during callbacks.
bool Enabled { get set }
Value: true if active; otherwise, false.
FixedRotation
Set this body to have fixed rotation. This causes the mass to be reset.
bool FixedRotation { get set }
Value: true if it has fixed rotation; otherwise, false.
JointList
Get the list of all joints attached to this body.
JointEdge JointList { get }
Value: The joint list.
ContactList
Get the list of all contacts attached to this body. Warning: this list changes during the time step and you may miss some collisions if you don't use callback events.
ContactEdge ContactList { get }
Value: The contact list.
Position
Get the world body origin position.
Vector2 Position { get set }
Rotation
Get the angle in radians.
float Rotation { get set }
IgnoreGravity
Gets or sets a value indicating whether this body ignores gravity.
bool IgnoreGravity { get set }
Value: true if it ignores gravity; otherwise, false.
WorldCenter
Get the world position of the center of mass.
Vector2 WorldCenter { get }
Value: The world position.
LocalCenter
Get the local position of the center of mass. Warning: This property is readonly during callbacks.
Vector2 LocalCenter { get set }
Value: The local position.
Mass
Gets or sets the mass. Usually in kilograms (kg). Warning: This property is readonly during callbacks.
float Mass { get set }
Value: The mass.
Inertia
Get or set the rotational inertia of the body about the local origin. usually in kg-m^2. Warning: This property is readonly during callbacks.
float Inertia { get set }
Value: The inertia.
IgnoreCCD
bool IgnoreCCD { get set }
Fields
ControllerFilter
ControllerFilter ControllerFilter
Tag
Set the user data. Use this to store your application specific data.
object Tag
Value: The user data.
FixtureList
Gets all the fixtures attached to this body.
FixtureCollection FixtureList
Value: The fixture list.
Methods
ResetDynamics
Resets the dynamics of this body. Sets torque, force and linear/angular velocity to 0
void ResetDynamics()
Add
Warning: This method is locked during callbacks.
void Add(Fixture fixture)
Parameters:
| Name | Type | Description |
|---|---|---|
fixture |
tainicom.Aether.Physics2D.Dynamics.Fixture |
Exceptions:
System.InvalidOperationException— Thrown when the world is Locked/Stepping.
Remove virtual
Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture. This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly destroyed when the body is destroyed. Warning: This method is locked during callbacks.
void Remove(Fixture fixture)
Parameters:
| Name | Type | Description |
|---|---|---|
fixture |
tainicom.Aether.Physics2D.Dynamics.Fixture |
The fixture to be removed. |
Exceptions:
System.InvalidOperationException— Thrown when the world is Locked/Stepping.
SetTransform
Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior. Warning: This method is locked during callbacks.
void SetTransform(ref Vector2 position, float rotation)
Parameters:
| Name | Type | Description |
|---|---|---|
position |
ref Strawberry.Math.Vector2 |
The world position of the body's local origin. |
rotation |
System.Single |
The world rotation in radians. |
Exceptions:
System.InvalidOperationException— Thrown when the world is Locked/Stepping.
SetTransform
Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior. Warning: This method is locked during callbacks.
void SetTransform(Vector2 position, float rotation)
Parameters:
| Name | Type | Description |
|---|---|---|
position |
Strawberry.Math.Vector2 |
The world position of the body's local origin. |
rotation |
System.Single |
The world rotation in radians. |
Exceptions:
System.InvalidOperationException— Thrown when the world is Locked/Stepping.
SetTransformIgnoreContacts
For teleporting a body without considering new contacts immediately. Warning: This method is locked during callbacks.
void SetTransformIgnoreContacts(ref Vector2 position, float angle)
Parameters:
| Name | Type | Description |
|---|---|---|
position |
ref Strawberry.Math.Vector2 |
The position. |
angle |
System.Single |
The angle. |
Exceptions:
System.InvalidOperationException— Thrown when the world is Locked/Stepping.
GetTransform
Get the body transform for the body's origin.
Transform GetTransform()
GetTransform
Get the body transform for the body's origin.
void GetTransform(out Transform transform)
Parameters:
| Name | Type | Description |
|---|---|---|
transform |
out tainicom.Aether.Physics2D.Common.Transform |
The transform of the body's origin. |
ApplyForce
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
void ApplyForce(Vector2 force, Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
force |
Strawberry.Math.Vector2 |
The world force vector, usually in Newtons (N). |
point |
Strawberry.Math.Vector2 |
The world position of the point of application. |
ApplyForce
Applies a force at the center of mass.
void ApplyForce(ref Vector2 force)
Parameters:
| Name | Type | Description |
|---|---|---|
force |
ref Strawberry.Math.Vector2 |
The force. |
ApplyForce
Applies a force at the center of mass.
void ApplyForce(Vector2 force)
Parameters:
| Name | Type | Description |
|---|---|---|
force |
Strawberry.Math.Vector2 |
The force. |
ApplyForce
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up the body.
void ApplyForce(ref Vector2 force, ref Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
force |
ref Strawberry.Math.Vector2 |
The world force vector, usually in Newtons (N). |
point |
ref Strawberry.Math.Vector2 |
The world position of the point of application. |
ApplyTorque
Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
void ApplyTorque(float torque)
Parameters:
| Name | Type | Description |
|---|---|---|
torque |
System.Single |
The torque about the z-axis (out of the screen), usually in N-m. |
ApplyLinearImpulse
Apply an impulse at a point. This immediately modifies the velocity. This wakes up the body.
void ApplyLinearImpulse(Vector2 impulse)
Parameters:
| Name | Type | Description |
|---|---|---|
impulse |
Strawberry.Math.Vector2 |
The world impulse vector, usually in N-seconds or kg-m/s. |
ApplyLinearImpulse
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.
void ApplyLinearImpulse(Vector2 impulse, Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
impulse |
Strawberry.Math.Vector2 |
The world impulse vector, usually in N-seconds or kg-m/s. |
point |
Strawberry.Math.Vector2 |
The world position of the point of application. |
ApplyLinearImpulse
Apply an impulse at a point. This immediately modifies the velocity. This wakes up the body.
void ApplyLinearImpulse(ref Vector2 impulse)
Parameters:
| Name | Type | Description |
|---|---|---|
impulse |
ref Strawberry.Math.Vector2 |
The world impulse vector, usually in N-seconds or kg-m/s. |
ApplyLinearImpulse
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This wakes up the body.
void ApplyLinearImpulse(ref Vector2 impulse, ref Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
impulse |
ref Strawberry.Math.Vector2 |
The world impulse vector, usually in N-seconds or kg-m/s. |
point |
ref Strawberry.Math.Vector2 |
The world position of the point of application. |
ApplyAngularImpulse
Apply an angular impulse.
void ApplyAngularImpulse(float impulse)
Parameters:
| Name | Type | Description |
|---|---|---|
impulse |
System.Single |
The angular impulse in units of kgmm/s. |
ResetMassData
This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.
void ResetMassData()
GetWorldPoint
Get the world coordinates of a point given the local coordinates.
Vector2 GetWorldPoint(ref Vector2 localPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
localPoint |
ref Strawberry.Math.Vector2 |
A point on the body measured relative the the body's origin. |
Returns: The same point expressed in world coordinates.
GetWorldPoint
Get the world coordinates of a point given the local coordinates.
Vector2 GetWorldPoint(Vector2 localPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
localPoint |
Strawberry.Math.Vector2 |
A point on the body measured relative the the body's origin. |
Returns: The same point expressed in world coordinates.
GetWorldVector
Get the world coordinates of a vector given the local coordinates. Note that the vector only takes the rotation into account, not the position.
Vector2 GetWorldVector(ref Vector2 localVector)
Parameters:
| Name | Type | Description |
|---|---|---|
localVector |
ref Strawberry.Math.Vector2 |
A vector fixed in the body. |
Returns: The same vector expressed in world coordinates.
GetWorldVector
Get the world coordinates of a vector given the local coordinates.
Vector2 GetWorldVector(Vector2 localVector)
Parameters:
| Name | Type | Description |
|---|---|---|
localVector |
Strawberry.Math.Vector2 |
A vector fixed in the body. |
Returns: The same vector expressed in world coordinates.
GetLocalPoint
Gets a local point relative to the body's origin given a world point. Note that the vector only takes the rotation into account, not the position.
Vector2 GetLocalPoint(ref Vector2 worldPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
worldPoint |
ref Strawberry.Math.Vector2 |
A point in world coordinates. |
Returns: The corresponding local point relative to the body's origin.
GetLocalPoint
Gets a local point relative to the body's origin given a world point.
Vector2 GetLocalPoint(Vector2 worldPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
worldPoint |
Strawberry.Math.Vector2 |
A point in world coordinates. |
Returns: The corresponding local point relative to the body's origin.
GetLocalVector
Gets a local vector given a world vector. Note that the vector only takes the rotation into account, not the position.
Vector2 GetLocalVector(ref Vector2 worldVector)
Parameters:
| Name | Type | Description |
|---|---|---|
worldVector |
ref Strawberry.Math.Vector2 |
A vector in world coordinates. |
Returns: The corresponding local vector.
GetLocalVector
Gets a local vector given a world vector. Note that the vector only takes the rotation into account, not the position.
Vector2 GetLocalVector(Vector2 worldVector)
Parameters:
| Name | Type | Description |
|---|---|---|
worldVector |
Strawberry.Math.Vector2 |
A vector in world coordinates. |
Returns: The corresponding local vector.
GetLinearVelocityFromWorldPoint
Get the world linear velocity of a world point attached to this body.
Vector2 GetLinearVelocityFromWorldPoint(Vector2 worldPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
worldPoint |
Strawberry.Math.Vector2 |
A point in world coordinates. |
Returns: The world velocity of a point.
GetLinearVelocityFromWorldPoint
Get the world linear velocity of a world point attached to this body.
Vector2 GetLinearVelocityFromWorldPoint(ref Vector2 worldPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
worldPoint |
ref Strawberry.Math.Vector2 |
A point in world coordinates. |
Returns: The world velocity of a point.
GetLinearVelocityFromLocalPoint
Get the world velocity of a local point.
Vector2 GetLinearVelocityFromLocalPoint(Vector2 localPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
localPoint |
Strawberry.Math.Vector2 |
A point in local coordinates. |
Returns: The world velocity of a point.
GetLinearVelocityFromLocalPoint
Get the world velocity of a local point.
Vector2 GetLinearVelocityFromLocalPoint(ref Vector2 localPoint)
Parameters:
| Name | Type | Description |
|---|---|---|
localPoint |
ref Strawberry.Math.Vector2 |
A point in local coordinates. |
Returns: The world velocity of a point.
SetRestitution
Set restitution on all fixtures. Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetRestitution(float restitution)
Parameters:
| Name | Type | Description |
|---|---|---|
restitution |
System.Single |
Remarks: Deprecated in version 1.6
SetFriction
Set friction on all fixtures. Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetFriction(float friction)
Parameters:
| Name | Type | Description |
|---|---|---|
friction |
System.Single |
Remarks: Deprecated in version 1.6
SetCollisionCategories
Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetCollisionCategories(Category category)
Parameters:
| Name | Type | Description |
|---|---|---|
category |
tainicom.Aether.Physics2D.Dynamics.Category |
Remarks: Deprecated in version 1.6
SetCollidesWith
Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetCollidesWith(Category category)
Parameters:
| Name | Type | Description |
|---|---|---|
category |
tainicom.Aether.Physics2D.Dynamics.Category |
Remarks: Deprecated in version 1.6
SetCollisionGroup
Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetCollisionGroup(short collisionGroup)
Parameters:
| Name | Type | Description |
|---|---|---|
collisionGroup |
System.Int16 |
Remarks: Deprecated in version 1.6
SetIsSensor
Warning: This method applies the value on existing Fixtures. It's not a property of Body.
void SetIsSensor(bool isSensor)
Parameters:
| Name | Type | Description |
|---|---|---|
isSensor |
System.Boolean |
Remarks: Deprecated in version 1.6
Clone
Makes a clone of the body. Fixtures and therefore shapes are not included. Use DeepClone() to clone the body, as well as fixtures and shapes.
Body Clone(World world = null)
Parameters:
| Name | Type | Description |
|---|---|---|
world |
tainicom.Aether.Physics2D.Dynamics.World = null |
DeepClone
Clones the body and all attached fixtures and shapes. Simply said, it makes a complete copy of the body.
Body DeepClone(World world = null)
Parameters:
| Name | Type | Description |
|---|---|---|
world |
tainicom.Aether.Physics2D.Dynamics.World = null |
CreateFixture virtual
Creates a fixture and attach it to this body. If the density is non-zero, this function automatically updates the mass of the body. Contacts are not created until the next time step. Warning: This method is locked during callbacks.
Fixture CreateFixture(Shape shape)
Parameters:
| Name | Type | Description |
|---|---|---|
shape |
tainicom.Aether.Physics2D.Collision.Shapes.Shape |
The shape. |
CreateEdge
Fixture CreateEdge(Vector2 start, Vector2 end)
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Strawberry.Math.Vector2 |
|
end |
Strawberry.Math.Vector2 |
CreateChainShape
Fixture CreateChainShape(Vertices vertices)
Parameters:
| Name | Type | Description |
|---|---|---|
vertices |
tainicom.Aether.Physics2D.Common.Vertices |
CreateLoopShape
Fixture CreateLoopShape(Vertices vertices)
Parameters:
| Name | Type | Description |
|---|---|---|
vertices |
tainicom.Aether.Physics2D.Common.Vertices |
CreateRectangle
Fixture CreateRectangle(float width, float height, float density, Vector2 offset)
Parameters:
| Name | Type | Description |
|---|---|---|
width |
System.Single |
|
height |
System.Single |
|
density |
System.Single |
|
offset |
Strawberry.Math.Vector2 |
CreateCircle
Fixture CreateCircle(float radius, float density)
Parameters:
| Name | Type | Description |
|---|---|---|
radius |
System.Single |
|
density |
System.Single |
CreateCircle
Fixture CreateCircle(float radius, float density, Vector2 offset)
Parameters:
| Name | Type | Description |
|---|---|---|
radius |
System.Single |
|
density |
System.Single |
|
offset |
Strawberry.Math.Vector2 |
CreatePolygon
Fixture CreatePolygon(Vertices vertices, float density)
Parameters:
| Name | Type | Description |
|---|---|---|
vertices |
tainicom.Aether.Physics2D.Common.Vertices |
|
density |
System.Single |
CreateEllipse
Fixture CreateEllipse(float xRadius, float yRadius, int edges, float density)
Parameters:
| Name | Type | Description |
|---|---|---|
xRadius |
System.Single |
|
yRadius |
System.Single |
|
edges |
System.Int32 |
|
density |
System.Single |
CreateCompoundPolygon
List<Fixture> CreateCompoundPolygon(List<Vertices> list, float density)
Parameters:
| Name | Type | Description |
|---|---|---|
list |
System.Collections.Generic.List |
|
density |
System.Single |
CreateLineArc
Fixture CreateLineArc(float radians, int sides, float radius, bool closed)
Parameters:
| Name | Type | Description |
|---|---|---|
radians |
System.Single |
|
sides |
System.Int32 |
|
radius |
System.Single |
|
closed |
System.Boolean |
CreateSolidArc
List<Fixture> CreateSolidArc(float density, float radians, int sides, float radius)
Parameters:
| Name | Type | Description |
|---|---|---|
density |
System.Single |
|
radians |
System.Single |
|
sides |
System.Int32 |
|
radius |
System.Single |
Events
OnCollision
event OnCollisionEventHandler OnCollision
OnSeparation
event OnSeparationEventHandler OnSeparation