RigidBody3D class
Makes its entity a rigid body that PhysicsSystem3D simulates. It needs a Collider3D on the same entity for its shape.
Gameplay moves a dynamic body with forces, impulses or a velocity — all applied before the next step — and a kinematic or static one by writing its entity's transform.
Constructors
- RigidBody3D({BodyType3D bodyType = BodyType3D.dynamic, bool continuousCollision = false, double mass = 0.0, double friction = 0.5, double restitution = 0.0, double linearDamping = 0.05, double angularDamping = 0.05, double gravityScale = 1.0, bool isSensor = false, int layer = 0, bool canSleep = true, bool lockRotation = false, Vector3? initialVelocity, Vector3? initialAngularVelocity})
- A dynamic body on layer 0, by default.
Properties
- angularDamping ↔ double
-
How quickly its spin slows by itself. A change rebuilds the body.
getter/setter pair
- angularVelocity → Vector3
-
Its spin after the last step (rad/s).
final
- body ↔ int
-
The physics engine's body, or 0 while it has none.
getter/setter pair
- bodyType ↔ BodyType3D
-
Static, kinematic or dynamic. A change rebuilds the body.
getter/setter pair
- canSleep ↔ bool
-
Whether it may fall asleep at rest. A change rebuilds the body.
getter/setter pair
- componentType → Type
-
Type identifier for this component
no setterinherited
- continuousCollision ↔ bool
-
Continuous collision: a fast body is swept from where it was to where
it is each step, so it cannot pass through a thin wall. Costs more.
getter/setter pair
- friction ↔ double
-
Surface friction, usually 0–1.
getter/setter pair
- gravityScale ↔ double
-
Gravity on it, times this: 0 floats, 2 falls hard.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialAngularVelocity ↔ Vector3
-
Spin it starts with (rad/s).
getter/setter pair
- initialVelocity ↔ Vector3
-
Velocity it starts with (m/s).
getter/setter pair
- isAwake ↔ bool
-
Whether it was awake after the last step.
getter/setter pair
- isSensor ↔ bool
-
Whether it only reports what enters and leaves it
(SensorEnter3DEvent) instead of colliding. A change rebuilds it.
getter/setter pair
- layer ↔ int
-
Its collision layer, 0–15 (the project's
physics.json).getter/setter pair - linearDamping ↔ double
-
How quickly it slows by itself. A change rebuilds the body.
getter/setter pair
- linearVelocity → Vector3
-
Its velocity after the last step (m/s).
final
- lockRotation ↔ bool
-
Whether it never turns. A change rebuilds the body.
getter/setter pair
- mass ↔ double
-
Mass in kg; 0 works it out from the collider's volume.
getter/setter pair
- pendingAngularImpulse → Vector3
-
See pendingForce.
final
- pendingAngularVelocity ↔ Vector3?
-
A spin to set before the next step, or null.
getter/setter pair
- pendingForce → Vector3
-
Force, torque and impulses waiting for the next step.
final
- pendingImpulse → Vector3
-
See pendingForce.
final
- pendingTorque → Vector3
-
See pendingForce.
final
- pendingVelocity ↔ Vector3?
-
A velocity to set before the next step, or null.
getter/setter pair
- pendingWake ↔ bool
-
Whether to wake it before the next step.
getter/setter pair
- restitution ↔ double
-
Bounciness, 0–1.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addAngularImpulse(
Vector3 impulse) → void - Changes its spin at once, before the next step (N·m·s).
-
addForce(
Vector3 force) → void - Pushes it during the next step (N).
-
addImpulse(
Vector3 impulse) → void - Changes its velocity at once, before the next step (N·s).
-
addTorque(
Vector3 torque) → void - Turns it during the next step (N·m).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAttach(
EntityId entityId) → void -
Called when this component is added to an entity.
inherited
-
onDetach(
EntityId entityId) → void -
Called when this component is removed from an entity.
inherited
-
setAngularVelocity(
Vector3 velocity) → void - Sets its spin before the next step.
-
setVelocity(
Vector3 velocity) → void - Sets its velocity before the next step.
-
toString(
) → String -
A string representation of this object.
inherited
-
wakeUp(
) → void - Wakes it before the next step.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited