Table of Contents

Class PhysicsBody

Namespace
Axolotl2D.Physics
Assembly
Axolotl2D.dll

Creates a Box2D body and keeps its GameObject transform synchronized.

public sealed class PhysicsBody : Component, IDisposable
Inheritance
PhysicsBody
Implements
Inherited Members

Constructors

PhysicsBody(GameObject, PhysicsWorld)

Creates a Box2D body and keeps its GameObject transform synchronized.

public PhysicsBody(GameObject gameObject, PhysicsWorld world)

Parameters

gameObject GameObject
world PhysicsWorld

Properties

AngularDamping

public float AngularDamping { get; set; }

Property Value

float

BodyId

public B2BodyId BodyId { get; }

Property Value

B2BodyId

GravityScale

public float GravityScale { get; set; }

Property Value

float

HasBody

public bool HasBody { get; }

Property Value

bool

IsBullet

public bool IsBullet { get; set; }

Property Value

bool

LinearDamping

public float LinearDamping { get; set; }

Property Value

float

LinearVelocity

public Vector2 LinearVelocity { get; set; }

Property Value

Vector2

ShapeCount

public int ShapeCount { get; }

Property Value

int

Type

public B2BodyType Type { get; set; }

Property Value

B2BodyType

Methods

AddBox(Vector2, float, float, float)

public void AddBox(Vector2 size, float density = 1, float friction = 0.6, float restitution = 0)

Parameters

size Vector2
density float
friction float
restitution float

AddCircle(float, float, float, float)

public void AddCircle(float radius, float density = 1, float friction = 0.6, float restitution = 0)

Parameters

radius float
density float
friction float
restitution float

ApplyForce(Vector2)

public void ApplyForce(Vector2 force)

Parameters

force Vector2

ApplyLinearImpulse(Vector2)

public void ApplyLinearImpulse(Vector2 impulse)

Parameters

impulse Vector2

OnDestroy()

public override void OnDestroy()

OnDisable()

public override void OnDisable()

OnEnable()

public override void OnEnable()

Start()

public override void Start()

Teleport(Vector2, float)

public void Teleport(Vector2 worldPosition, float rotation)

Parameters

worldPosition Vector2
rotation float

Events

CollisionEntered

public event Action<PhysicsBody>? CollisionEntered

Event Type

Action<PhysicsBody>

CollisionExited

public event Action<PhysicsBody>? CollisionExited

Event Type

Action<PhysicsBody>