Skip to content

RigidBody2D ​

class in OpalScript

Simulates mass and velocity with Rapier 2D. Pair with Collider 2D so this object can hit and be hit.

Properties ​

MemberDescription
RigidBody2D.SimulationPositionRead-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.SimulationRotationRead-only simulation rotation in degrees from the latest physics step.
RigidBody2D.VelocityCurrent linear velocity in pixels per second. Negative Y moves up. Read-only; change it with SetVelocity or AddVelocity.
RigidBody2D.AngularVelocityCurrent rotational velocity (radians/s).
RigidBody2D.SleepingTrue while the body is at rest and not simulating.
RigidBody2D.SpeedCurrent overall speed (px/s).
RigidBody2D.BodyTypeDynamic = moved by physics/forces; Kinematic = moved by you but pushes others; Fixed = immovable (walls/floors).
RigidBody2D.EnabledWhether this component is enabled. Use SetEnabled to change it.

Methods ​

MemberDescription
RigidBody2D.SetVelocitySet linear velocity in pixels per second. Negative Y moves up. Replaces both axes and wakes the body; gravity continues to act.
RigidBody2D.AddVelocityAdd a velocity change in pixels per second to the current velocity, independent of mass.
RigidBody2D.ApplyImpulseApply a one-time world-space impulse. Velocity change equals impulse divided by mass; negative Y pushes up.
RigidBody2D.SetAngularVelocitySet angular velocity in radians per second and wake the body.
RigidBody2D.TeleportMove the physics body immediately to a world position in pixels.
RigidBody2D.SetEnabledEnable or disable this component's behavior.
RigidBody2D.SetDynamicUse a dynamic body, simulated by gravity, forces, and contacts.
RigidBody2D.SetFixedUse an immovable body.
RigidBody2D.SetKinematicUse a position-driven kinematic body.
RigidBody2D.SetVelocityKinematicUse a velocity-driven kinematic body.
RigidBody2D.PinToWeld 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.WakeWake the body so physics simulates it.
RigidBody2D.SleepPut the body to sleep.
RigidBody2D.IsDynamicWhether this body's type is dynamic.
RigidBody2D.IsKinematicWhether this body uses either kinematic mode.
RigidBody2D.IsMovingWhether the body has linear or angular motion.
RigidBody2D.IsSleepingWhether the physics solver has put the body to sleep.

See also ​