class PhysicsBody

book_4_sparkGenerated
code_blocksInput

Description

The PhysicsBody class in the Sandbox namespace represents a physics object within the game. An entity can have multiple physics objects, each consisting of one or more PhysicsShapes. This class provides various methods and properties to manipulate and interact with the physics body, such as applying forces, adding shapes, and checking overlaps.

Members

Properties

Member NameSummary
PositionPosition of this body in world coordinates.
WorldThe physics world this body belongs to.
RotationRotation of the physics body in world space.
ScaleObsolete.
VelocityLinear velocity of this body in world space.
AngularVelocityAngular velocity of this body in world space.
MassCenterCenter of mass for this physics body in world space coordinates.
LocalMassCenterCenter of mass for this physics body relative to its origin.
OverrideMassCenterIs this physics body mass calculated or set directly.
MassMass of this physics body.
GravityEnabledWhether gravity is enabled for this body or not.
EnableCollisionSoundsWhether to play collision sounds.
GravityScaleScale the gravity relative to the physics world's gravity.
UseControllerIf true, creates a controller for this physics body for keyframed physics objects.
EnableTouchEnables Touch callbacks on all PhysicsShapes of this body.
EnableTouchPersistsSets persistent touch events on all shapes of this body.
EnableSolidCollisionsSets solid collisions on all shapes of this body.
BodyTypeMovement type of physics body, either Static, Keyframed, Dynamic.
AutoSleepWhether this body is allowed to automatically go into "sleep" after inactivity.
TransformTransform of this physics body.
ShapeCountHow many shapes belong to this body.
ShapesAll shapes that belong to this body.
EnabledWhether this body is enabled or not.
MotionEnabledControls physics simulation on this body.
SleepingPhysics bodies automatically go to sleep after inactivity to save on performance.
SpeculativeContactEnabledObsolete.
ParentThe physics body we are attached to, if any.
SelfOrParentReturns Parent, or if there is no parent, returns itself.
PhysicsGroupThe physics group we belong to.
LinearDampingGeneric linear damping, i.e. how much the physics body will slow down on its own.
AngularDampingGeneric angular damping, i.e. how much the physics body will slow down on its own.
LinearDragAmount of air drag to be applied to linear movement.
AngularDragAmount of air drag to be applied to angular movement/rotation.
DragEnabledWhether air drag forces are enabled for this body.
InertiaThe diagonal elements of the inertia tensor matrix.
InertiaRotationThe orientation of the principal axes of inertia tensor matrix.
DensityReturns average of densities for all physics shapes of this body.
LastWaterEffectTime since last water splash effect. Used internally.
SurfaceMaterialSets surface material on all child PhysicsShapes.
SurfaceSurface material of the physics body.
GroupNameWhat is this body called in the group?
GroupIndexReturn the index of this body in its PhysicsGroup.
OnIntersectionStartEvent triggered when an intersection starts.
OnIntersectionUpdateEvent triggered when an intersection updates.
OnIntersectionEndEvent triggered when an intersection ends.
LockingPhysics lock state of the body.

Methods

Member NameSummary
MoveMoves the physics body to a new transform over a delta time.
AddSphereShapeAdds a sphere shape to the physics body.
AddCapsuleShapeAdds a capsule shape to the physics body.
AddBoxShapeAdds a box shape to the physics body.
AddHullShapeAdds a hull shape to the physics body.
AddCylinderShapeAdds a cylinder shape to the physics body.
AddConeShapeAdds a cone shape to the physics body.
AddMeshShapeAdds a mesh shape to the physics body.
AddHeightFieldShapeAdds a height field shape to the physics body.
AddCloneShapeAdds a clone of an existing shape to the physics body.
ClearShapesRemove all physics shapes, but not the physics body itself.
RebuildMassRebuilds mass from all shapes of this body based on their volume and physics properties.
RemoveCompletely removes this physics body.
ApplyImpulseApplies an impulse to the physics body.
ApplyImpulseAtApplies an impulse at a specific point on the physics body.
ApplyAngularImpulseApplies an angular impulse to the physics body.
ApplyForceApplies a force to the physics body.
ApplyForceAtApplies a force at a specific point on the physics body.
ApplyTorqueApplies a torque to the physics body.
ClearForcesClear accumulated linear forces during this physics frame that were not yet applied to the physics body.
ClearTorqueClear accumulated torque during this physics frame that were not yet applied to the physics body.
GetVelocityAtPointGets the velocity of the physics body at a specific point.
FindClosestPointFinds the closest point on the physics body to a given vector.
GetBoundsReturns Axis-Aligned Bounding Box (AABB) of this physics body.
LocalPointConverts a world point to a local point relative to the physics body.
WorldPointConverts a local point to a world point relative to the physics body.
MassCenterPointReturns a PhysicsPoint at the center of mass of this body.
CheckOverlapChecks if this physics body overlaps with another.
AddShapeAdds a shape to the physics body.
GetLerpedTransformGets the interpolated transform of the physics body at a specific time.
SmoothMoveMoves the physics body smoothly to a new position over time.
SmoothRotateRotates the physics body smoothly to a new orientation over time.