Table of Contents

Class b2BodyDef

Namespace
Gym.Box2D
Assembly
Gym.Environments.dll

A body definition: everything a body is created from (pybox2d's b2BodyDef). Reusable.

public class b2BodyDef
Inheritance
b2BodyDef
Inherited Members
Extension Methods

Remarks

Constructors

b2BodyDef()

A body definition with Box2D's defaults: a static body at the origin.

public b2BodyDef()

b2BodyDef(b2BodyType, b2Vec2?, double, IEnumerable<b2FixtureDef>?, IEnumerable<b2Shape>?, b2FixtureDef?, b2Vec2?, double, double, double, bool, bool, bool, bool, bool, double, object?)

A body definition from pybox2d's keyword arguments; scalars round to float32 as SWIG converts them, and a refused one raises pybox2d's Failed on kwargs for b2BodyDef.angle: … (its keyword named).

public b2BodyDef(b2BodyType type = b2BodyType.b2_staticBody, b2Vec2? position = null, double angle = 0, IEnumerable<b2FixtureDef>? fixtures = null, IEnumerable<b2Shape>? shapes = null, b2FixtureDef? shapeFixture = null, b2Vec2? linearVelocity = null, double angularVelocity = 0, double linearDamping = 0, double angularDamping = 0, bool allowSleep = true, bool awake = true, bool fixedRotation = false, bool bullet = false, bool active = true, double gravityScale = 1, object? userData = null)

Parameters

type b2BodyType

The body type.

position b2Vec2?

The body origin's world position (origin when null).

angle double

The angle in radians.

fixtures IEnumerable<b2FixtureDef>

The fixtures CreateBody(b2BodyDef) creates, in order.

shapes IEnumerable<b2Shape>

Shapes to create fixtures of with shapeFixture's material.

shapeFixture b2FixtureDef

The material for shapes.

linearVelocity b2Vec2?

The initial linear velocity (zero when null).

angularVelocity double

The initial angular velocity.

linearDamping double

The linear damping.

angularDamping double

The angular damping.

allowSleep bool

Whether the body may sleep.

awake bool

Whether it starts awake.

fixedRotation bool

Whether it may not rotate.

bullet bool

Whether it is a bullet.

active bool

Whether it starts active.

gravityScale double

The gravity scale.

userData object

The user data.

Exceptions

OverflowError

Thrown for a scalar beyond the float32 range.

Properties

Angle

The angle in radians (stored as float32).

public double Angle { get; set; }

Property Value

double

AngularVelocity

The initial angular velocity (stored as float32).

public double AngularVelocity { get; set; }

Property Value

double

Fixtures

The fixtures CreateBody(b2BodyDef) creates on the body, in order (pybox2d's fixtures).

public List<b2FixtureDef> Fixtures { get; }

Property Value

List<b2FixtureDef>

LinearVelocity

The initial linear velocity.

public b2Vec2 LinearVelocity { get; set; }

Property Value

b2Vec2

Position

The body origin's world position.

public b2Vec2 Position { get; set; }

Property Value

b2Vec2

ShapeFixture

The material for Shapes (pybox2d's shapeFixture; Box2D's defaults when null).

public b2FixtureDef? ShapeFixture { get; set; }

Property Value

b2FixtureDef

Shapes

Shapes CreateBody(b2BodyDef) creates fixtures of, after Fixtures (pybox2d's shapes).

public List<b2Shape> Shapes { get; }

Property Value

List<b2Shape>

Type

The body type.

public b2BodyType Type { get; set; }

Property Value

b2BodyType

UserData

The user data.

public object? UserData { get; set; }

Property Value

object