A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction. Body definitions are temporary objects used to bundle creation parameters.
More...
|
| BodyDef (BodyType type=BodyType.Static, Vec2 position=default, Rotation rotation=default, Vec2 linearVelocity=default, float angularVelocity=0f, float linearDamping=0f, float angularDamping=0f, float gravityScale=1f, float sleepThreshold=0.05f, bool enableSleep=true, bool isAwake=true, bool fixedRotation=false, bool isBullet=false, bool isEnabled=true, bool allowFastRotation=false, string? name=null, object? userData=null) |
| Construct a Body Definition with the supplied values.
|
|
| BodyDef () |
| Construct a Body Definition with the default values.
|
|
|
ref BodyType | Type [get] |
| The body type: static, kinematic, or dynamic.
|
|
ref Vec2 | Position [get] |
| The initial world position of the body. Bodies should be created with the desired position. Note: Creating bodies at the origin and then moving them nearly doubles the cost of body creation, especially if the body is moved after shapes have been added.
|
|
ref Rotation | Rotation [get] |
| The initial world rotation of the body.
|
|
ref Vec2 | LinearVelocity [get] |
| The initial linear velocity of the body's origin. Usually in meters per second.
|
|
ref float | AngularVelocity [get] |
| The initial angular velocity of the body. Radians per second.
|
|
ref float | LinearDamping [get] |
| Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1 but the damping effect becomes sensitive to the time step when the damping parameter is large. Generally linear damping is undesirable because it makes objects move slowly as if they are floating.
|
|
ref float | AngularDamping [get] |
| Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. Angular damping can be use slow down rotating bodies.
|
|
ref float | GravityScale [get] |
| Scale the gravity applied to this body. Non-dimensional.
|
|
ref float | SleepThreshold [get] |
| Sleep speed threshold, default is 0.05 meters per second.
|
|
string? | Name [get, set] |
| Optional body name for debugging. Up to 31 characters (excluding null termination)
|
|
object? | UserData [get, set] |
| Use this to store application specific body data.
|
|
bool | EnableSleep [get, set] |
| Set this flag to false if this body should never fall asleep.
|
|
bool | IsAwake [get, set] |
| Is this body initially awake or sleeping?
|
|
bool | FixedRotation [get, set] |
| Should this body be prevented from rotating? Useful for characters.
|
|
bool | IsBullet [get, set] |
| Treat this body as high speed object that performs continuous collision detection against dynamic and kinematic bodies, but not other bullet bodies. Warning: Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic continuous collision. They may interfere with joint constraints.
|
|
bool | IsEnabled [get, set] |
| Used to disable a body. A disabled body does not move or collide.
|
|
bool | AllowFastRotation [get, set] |
| This allows this body to bypass rotational speed limits. Should only be used for circular objects, like wheels.
|
|
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction. Body definitions are temporary objects used to bundle creation parameters.
◆ BodyDef()
Box2D.BodyDef.BodyDef |
( |
BodyType |
type = BodyType::Static , |
|
|
Vec2 |
position = default , |
|
|
Rotation |
rotation = default , |
|
|
Vec2 |
linearVelocity = default , |
|
|
float |
angularVelocity = 0f , |
|
|
float |
linearDamping = 0f , |
|
|
float |
angularDamping = 0f , |
|
|
float |
gravityScale = 1f , |
|
|
float |
sleepThreshold = 0::05f , |
|
|
bool |
enableSleep = true , |
|
|
bool |
isAwake = true , |
|
|
bool |
fixedRotation = false , |
|
|
bool |
isBullet = false , |
|
|
bool |
isEnabled = true , |
|
|
bool |
allowFastRotation = false , |
|
|
string? |
name = null , |
|
|
object? |
userData = null |
|
) |
| |
|
inline |
Construct a Body Definition with the supplied values.
- Parameters
-
type | The BodyType of the body. |
position | The initial world position of the body. Bodies should be created with the desired position. |
rotation | The initial world rotation of the body. |
linearVelocity | The initial linear velocity of the body's origin. Usually in meters per second. |
angularVelocity | The initial angular velocity of the body. Radians per second. |
linearDamping | Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1 but the damping effect becomes sensitive to the time step when the damping parameter is large. Generally linear damping is undesirable because it makes objects move slowly as if they are floating. |
angularDamping | Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. Angular damping can be use slow down rotating bodies. |
gravityScale | Scale the gravity applied to this body. Non-dimensional. |
sleepThreshold | Sleep speed threshold, default is 0.05 meters per second |
enableSleep | Set this flag to false if this body should never fall asleep. |
isAwake | Is this body initially awake or sleeping? |
fixedRotation | Should this body be prevented from rotating? Useful for characters. |
isBullet | Treat this body as high speed object that performs continuous collision detection against dynamic and kinematic bodies, but not other bullet bodies. Warning: Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic continuous collision. They may interfere with joint constraints. |
isEnabled | Used to disable a body. A disabled body does not move or collide. |
allowFastRotation | This allows this body to bypass rotational speed limits. Should only be used for circular objects, like wheels. |
name | Optional body name for debugging. Up to 31 characters (excluding null termination) |
userData | Use this to store application specific body data. |
The documentation for this class was generated from the following file:
- src/Box2DBindings/Defs/BodyDef.cs