RigidBody2D
class in OpalScript
Simulates mass and velocity with Rapier 2D. Pair with Collider 2D so this object can hit and be hit.
Properties
| Member | Description |
|---|---|
| RigidBody2D.SimulationPosition | Read-only world position from the latest physics step, in pixels. Unlike Transform.WorldPosition, this is the simulation pose rather than the interpolated visual pose. |
| RigidBody2D.SimulationRotation | Read-only simulation rotation in degrees from the latest physics step. |
| RigidBody2D.Velocity | Current linear velocity in pixels per second. Negative Y moves up. Read-only; change it with SetVelocity or AddVelocity. |
| RigidBody2D.AngularVelocity | Current rotational velocity (radians/s). |
| RigidBody2D.Sleeping | True while the body is at rest and not simulating. |
| RigidBody2D.Speed | Current overall speed (px/s). |
| RigidBody2D.BodyType | Dynamic = moved by physics/forces; Kinematic = moved by you but pushes others; Fixed = immovable (walls/floors). |
| RigidBody2D.Enabled | Whether this component is enabled. Use SetEnabled to change it. |
Methods
| Member | Description |
|---|---|
| RigidBody2D.SetVelocity | Set linear velocity in pixels per second. Negative Y moves up. Replaces both axes and wakes the body; gravity continues to act. |
| RigidBody2D.AddVelocity | Add a velocity change in pixels per second to the current velocity, independent of mass. |
| RigidBody2D.ApplyImpulse | Apply a one-time world-space impulse. Velocity change equals impulse divided by mass; negative Y pushes up. |
| RigidBody2D.SetAngularVelocity | Set angular velocity in radians per second and wake the body. |
| RigidBody2D.Teleport | Move the physics body immediately to a world position in pixels. |
| RigidBody2D.SetEnabled | Enable or disable this component's behavior. |
| RigidBody2D.SetDynamic | Use a dynamic body, simulated by gravity, forces, and contacts. |
| RigidBody2D.SetFixed | Use an immovable body. |
| RigidBody2D.SetKinematic | Use a position-driven kinematic body. |
| RigidBody2D.SetVelocityKinematic | Use a velocity-driven kinematic body. |
| RigidBody2D.PinTo | Weld this body to another with a fixed joint (arrow sticking). Uses the midpoint between centers as the pin point when At Contact Point is on. Repeated calls replace the previous weld to the same target. |
| RigidBody2D.Wake | Wake the body so physics simulates it. |
| RigidBody2D.Sleep | Put the body to sleep. |
| RigidBody2D.IsDynamic | Whether this body's type is dynamic. |
| RigidBody2D.IsKinematic | Whether this body uses either kinematic mode. |
| RigidBody2D.IsMoving | Whether the body has linear or angular motion. |
| RigidBody2D.IsSleeping | Whether the physics solver has put the body to sleep. |