Summary

Represents a physics object. An entity can have multiple physics objects. See PhysicsBody.PhysicsGroup. A physics objects consists of one or more PhysicsShapes.

Constructors

PhysicsBody

Properties

AngularDamping Generic angular damping, i.e. how much the physics body will slow down on its own.
AngularDragobsolete
AngularVelocity Angular velocity of this body in world space.
AutoSleep Whether this body is allowed to automatically go into "sleep" after a certain amount of time of inactivity. Sandbox.PhysicsBody.Sleeping for more info on the sleep mechanic.
BodyType Movement type of physics body, either Static, Keyframed, Dynamic Note: If this body is networked and dynamic, it will return Keyframed on the client
Component The component that created this body
Density Returns average of densities for all physics shapes of this body. This is based on Sandbox.PhysicsShape.SurfaceMaterial of each shape.
DragEnabledobsolete
EnableCollisionSounds Whether to play collision sounds
Enabled Whether this body is enabled or not. Disables collisions, physics simulation, touch events, trace queries, etc.
EnableSolidCollisions Sets Sandbox.PhysicsShape.EnableSolidCollisions on all shapes of this body. <br /><br /> Returns true if ANY of the physics shapes have solid collisions enabled.
EnableTouch Enables Touch callbacks on all <see cref="T:Sandbox.PhysicsShape">PhysicsShapes</see> of this body. Returns true if ANY of the physics shapes have touch events enabled.
EnableTouchPersists Sets Sandbox.PhysicsShape.EnableTouchPersists on all shapes of this body. <br /><br /> Returns true if ANY of the physics shapes have persistent touch events enabled.
GameObject The GameObject that created this body
GravityEnabled Whether gravity is enabled for this body or not.
GravityScale Scale the gravity relative to Sandbox.PhysicsWorld.Gravity. 2 is double the gravity, etc.
GroupIndex Return the index of this body in its PhysicsGroup
GroupName What is this body called in the group?
Inertia The diagonal elements of the local inertia tensor matrix.
InertiaRotation The orientation of the principal axes of local inertia tensor matrix.
LastWaterEffect Time since last water splash effect. Used internally.
LinearDamping Generic linear damping, i.e. how much the physics body will slow down on its own.
LinearDragobsolete
LocalMassCenter Center of mass for this physics body relative to its <see cref="P:Sandbox.PhysicsBody.Position">origin</see>.
Locking
Mass Mass of this physics body.
MassCenter Center of mass for this physics body in world space coordinates.
MotionEnabled Controls physics simulation on this body.
OnIntersectionEnd
OnIntersectionStart
OnIntersectionUpdate
OverrideMassCenter Is this physics body mass calculated or set directly.
Parent The physics body we are attached to, if any
PhysicsGroup The physics group we belong to.
Position Position of this body in world coordinates.
Rotation Rotation of the physics body in world space.
Scaleobsolete
SelfOrParent A convenience property, returns <see cref="P:Sandbox.PhysicsBody.Parent">Parent</see>, or if there is no parent, returns itself.
ShapeCount How many shapes belong to this body.
Shapes All shapes that belong to this body.
Sleeping Physics bodies automatically go to sleep after a certain amount of time of inactivity to save on performance. You can use this to wake the body up, or prematurely send it to sleep.
SpeculativeContactEnabledobsolete If enabled, this physics body will move slightly ahead each frame based on its velocities.
Surface
SurfaceMaterial Sets Sandbox.PhysicsShape.SurfaceMaterial on all child <see cref="T:Sandbox.PhysicsShape">PhysicsShape</see>s.
Transform Transform of this physics body.
UseController If true we'll create a controller for this physics body. This is useful for keyframed physics objects that need to push things. The controller will sweep as the entity moves, rather than teleporting the object.. which works better when pushing dynamic objects etc.
Velocity Linear velocity of this body in world space.
World The physics world this body belongs to.

Methods

AddBoxShape Add a box shape to this body.
AddCapsuleShape Add a capsule shape to this body.
AddCloneShapeobsolete
AddConeShape Add a cone shape to this body.
AddCylinderShape Add a cylinder shape to this body.
AddHeightFieldShape
AddHullShape
AddMeshShape
AddShape Add a shape from a physics hull
AddSphereShape Add a sphere shape to this body.
ApplyAngularImpulse Applies instant angular impulse (i.e. a bullet impact) to this body. For continuous force (i.e. a moving car), use Sandbox.PhysicsBody.ApplyTorque(Vector3)
ApplyForce Applies force to this body at the center of mass. This force will only be applied on the next physics frame and is scaled with physics timestep.
ApplyForceAt Applies force to this body at given position. This force will only be applied on the next physics frame and is scaled with physics timestep.
ApplyImpulse Applies instant linear impulse (i.e. a bullet impact) to this body at its center of mass. For continuous force (i.e. a moving car), use Sandbox.PhysicsBody.ApplyForce(Vector3)
ApplyImpulseAt Applies instant linear impulse (i.e. a bullet impact) to this body at given position. For continuous force (i.e. a moving car), use Sandbox.PhysicsBody.ApplyForceAt(Vector3,Vector3)
ApplyTorque Applies angular velocity to this body. This force will only be applied on the next physics frame and is scaled with physics timestep.
CheckOverlap Checks if another body overlaps us, ignoring all collision rules
ClearForces Clear accumulated linear forces (Sandbox.PhysicsBody.ApplyForce(Vector3) and Sandbox.PhysicsBody.ApplyForceAt(Vector3,Vector3)) during this physics frame that were not yet applied to the physics body.
ClearShapes Remove all physics shapes, but not the physics body itself.
ClearTorque Clear accumulated torque (angular force, Sandbox.PhysicsBody.ApplyTorque(Vector3)) during this physics frame that were not yet applied to the physics body.
FindClosestPoint Returns the closest point to the given one between all shapes of this body.
GetBounds Returns Axis-Aligned Bounding Box (AABB) of this physics body.
GetGameObjectobsolete
GetLerpedTransform When the physics world is run at a fixed timestep, getting the positions of bodies will not be smooth. You can use this function to get the lerped position between steps, to make things super awesome.
GetVelocityAtPoint Returns the world space velocity of a point of the object. This is useful for objects rotating around their own axis/origin.
LocalPoint Convenience function that returns a Sandbox.Physics.PhysicsPoint from a position relative to this body.
MassCenterPoint Returns a Sandbox.Physics.PhysicsPoint at the center of mass of this body.
Move Move to a new position. Unlike Transform, if you have `UseController` enabled, this will sweep the shadow to the new position, rather than teleporting there.
RebuildMass Meant to be only used on <b>dynamic</b> bodies, rebuilds mass from all shapes of this body based on their volume and <see cref="P:Sandbox.PhysicsBody.Surface">physics properties</see>, for cases where they may have changed.
Remove Completely removes this physics body.
ResetInertiaTensor Resets the inertia tensor to its calculated values.
SetComponentSourceobsolete
SetInertiaTensor Sets the inertia tensor using the given moments and rotation.
SmoothMove Move body to this position in a way that cooperates with the physics system. This is quite good for things like grabbing and moving objects.
SmoothRotate Rotate the body to this position in a way that cooperates with the physics system.
WorldPoint Convenience function that returns a Sandbox.Physics.PhysicsPoint for this body from a world space position.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.