s&
newspaper
About
info
About s&box
newspaper
Latest News
published_with_changes
Changes
map
Roadmap
monitoring
Metrics
games
Games
sports_esports
Browse Games
rocket
Discover Games
business_center
Workshop
sports_esports
Games
landscape
Maps
chair
Models
texture
Materials
apparel
Clothing
construction
More..
forum
Forum
docs
Docs
docs
Documentation
dashboard
Api Reference
input
Log in with Steam
chevron_left
Change Language
简体中文
English
Русский
Español
Português-Brasil
Deutsch
日本語
Français
Polski
Türkçe
한국어
Pirate
Italiano
ไทย
繁體中文
Українська
Čeština
Nederlands
Magyar
Dansk
Suomi
Svenska
Norsk
Ελληνικά
Română
Български
Tiếng Việt
Bahasa Indonesia
Español-Latinoamérica
العربية
Api
Classes
PhysicsBody
chevron_left
Classes
class
PhysicsBody
search
Constructors
functions
PhysicsBody
Properties
data_object
AngularDamping
remove_circle
AngularDrag
data_object
AngularVelocity
data_object
AutoSleep
data_object
BodyType
data_object
Component
data_object
Density
remove_circle
DragEnabled
data_object
EnableCollisionSounds
data_object
Enabled
data_object
EnableSolidCollisions
data_object
EnableTouch
data_object
EnableTouchPersists
data_object
EnhancedCcd
data_object
GameObject
data_object
GravityEnabled
data_object
GravityScale
data_object
GroupIndex
data_object
GroupName
data_object
Inertia
data_object
InertiaRotation
data_object
LastWaterEffect
data_object
LinearDamping
remove_circle
LinearDrag
data_object
LocalMassCenter
data_object
Locking
data_object
Mass
data_object
MassCenter
data_object
MotionEnabled
data_object
OnIntersectionEnd
data_object
OnIntersectionStart
data_object
OnIntersectionUpdate
data_object
OverrideMassCenter
data_object
Parent
data_object
PhysicsGroup
data_object
Position
data_object
Rotation
remove_circle
Scale
data_object
SelfOrParent
data_object
ShapeCount
data_object
Shapes
data_object
Sleeping
data_object
SleepThreshold
remove_circle
SpeculativeContactEnabled
data_object
Surface
data_object
SurfaceMaterial
data_object
Transform
data_object
UseController
data_object
Velocity
data_object
World
Methods
functions
AddBoxShape
functions
AddCapsuleShape
remove_circle
AddCloneShape
functions
AddConeShape
functions
AddCylinderShape
functions
AddHeightFieldShape
functions
AddHullShape
functions
AddMeshShape
functions
AddShape
functions
AddSphereShape
functions
ApplyAngularImpulse
functions
ApplyForce
functions
ApplyForceAt
functions
ApplyImpulse
functions
ApplyImpulseAt
functions
ApplyTorque
functions
CheckOverlap
functions
ClearForces
functions
ClearShapes
functions
ClearTorque
functions
FindClosestPoint
functions
GetBounds
remove_circle
GetGameObject
functions
GetLerpedTransform
functions
GetVelocityAtPoint
functions
LocalPoint
functions
MassCenterPoint
functions
Move
functions
RebuildMass
functions
Remove
functions
ResetInertiaTensor
remove_circle
SetComponentSource
functions
SetInertiaTensor
functions
SmoothMove
functions
SmoothRotate
functions
WorldPoint
menu
PhysicsBody
Represents a physics object. An entity can have multiple physics objects. See <see cref="P:Sandbox.PhysicsBody.PhysicsGroup">PhysicsGroup</see>. A physics objects consists of one or more <see cref="T:Sandbox.PhysicsShape">PhysicsShape</see>s.
class
Sandbox
.
sealed
Sandbox.Engine
build
Constructors
1
PhysicsBody
(
world
)
data_object
Properties
50
AngularDamping
float
Generic angular damping, i.e. how much the physics body will slow down on its own.
AngularDrag
obsolete
float
AngularVelocity
Vector3
Angular velocity of this body in world space.
AutoSleep
bool
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
PhysicsBodyType
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
Component
The component that created this body
Density
float
Returns average of densities for all physics shapes of this body. This is based on Sandbox.PhysicsShape.SurfaceMaterial of each shape.
DragEnabled
obsolete
bool
EnableCollisionSounds
bool
Whether to play collision sounds
Enabled
bool
Whether this body is enabled or not. Disables collisions, physics simulation, touch events, trace queries, etc.
EnableSolidCollisions
bool
Sets Sandbox.PhysicsShape.EnableSolidCollisions on all shapes of this body.
Returns true if ANY of the physics shapes have solid collisions enabled.
EnableTouch
bool
Enables Touch callbacks on all
PhysicsShapes
of this body. Returns true if ANY of the physics shapes have touch events enabled.
EnableTouchPersists
bool
Sets Sandbox.PhysicsShape.EnableTouchPersists on all shapes of this body.
Returns true if ANY of the physics shapes have persistent touch events enabled.
EnhancedCcd
bool
Enable enhanced continuous collision detection (CCD) for this body. When enabled, the body performs CCD against dynamic bodies (but not against other bodies with enhanced CCD enabled). This is useful for fast-moving objects like bullets or rockets that need reliable collision detection.
GameObject
GameObject
The GameObject that created this body
GravityEnabled
bool
Whether gravity is enabled for this body or not.
GravityScale
float
Scale the gravity relative to Sandbox.PhysicsWorld.Gravity. 2 is double the gravity, etc.
GroupIndex
int
Return the index of this body in its PhysicsGroup
GroupName
string
What is this body called in the group?
Inertia
Vector3
The diagonal elements of the local inertia tensor matrix.
InertiaRotation
Rotation
The orientation of the principal axes of local inertia tensor matrix.
LastWaterEffect
RealTimeSince
Time since last water splash effect. Used internally.
LinearDamping
float
Generic linear damping, i.e. how much the physics body will slow down on its own.
LinearDrag
obsolete
float
LocalMassCenter
Vector3
Center of mass for this physics body relative to its
origin
.
Locking
PhysicsLock
Mass
float
Mass of this physics body.
MassCenter
Vector3
Center of mass for this physics body in world space coordinates.
MotionEnabled
bool
Controls physics simulation on this body.
OnIntersectionEnd
Action`1
OnIntersectionStart
Action`1
OnIntersectionUpdate
Action`1
OverrideMassCenter
bool
Is this physics body mass calculated or set directly.
Parent
PhysicsBody
The physics body we are attached to, if any
PhysicsGroup
PhysicsGroup
The physics group we belong to.
Position
Vector3
Position of this body in world coordinates.
Rotation
Rotation
Rotation of the physics body in world space.
Scale
obsolete
float
SelfOrParent
PhysicsBody
A convenience property, returns
Parent
, or if there is no parent, returns itself.
ShapeCount
int
How many shapes belong to this body.
Shapes
IEnumerable`1
All shapes that belong to this body.
Sleeping
bool
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.
SleepThreshold
float
The speed threshold below which this body will be put to sleep. Units per second. The default is about 2 units/sec. Increase this to make bodies sleep sooner, which is useful for stacking stability.
SpeculativeContactEnabled
obsolete
bool
If enabled, this physics body will move slightly ahead each frame based on its velocities.
Surface
Surface
SurfaceMaterial
string
Sets Sandbox.PhysicsShape.SurfaceMaterial on all child
PhysicsShape
s.
Transform
Transform
Transform of this physics body.
UseController
bool
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
Vector3
Linear velocity of this body in world space.
World
PhysicsWorld
The physics world this body belongs to.
functions
Methods
36
AddBoxShape
(
position
,
rotation
,
extent
,
rebuildMass
)
PhysicsShape
Add a box shape to this body.
AddCapsuleShape
(
center
,
center2
,
radius
,
rebuildMass
)
PhysicsShape
Add a capsule shape to this body.
AddCloneShape
(
shape
)
obsolete
PhysicsShape
AddConeShape
(
position
,
rotation
,
height
,
radius1
,
radius2
,
slices
)
PhysicsShape
Add a cone shape to this body.
AddCylinderShape
(
position
,
rotation
,
height
,
radius
,
slices
)
PhysicsShape
Add a cylinder shape to this body.
AddHeightFieldShape
(
heights
,
materials
,
sizeX
,
sizeY
,
sizeScale
,
heightScale
)
PhysicsShape
AddHullShape
(
position
,
rotation
,
points
,
rebuildMass
)
PhysicsShape
AddMeshShape
(
vertices
,
indices
)
PhysicsShape
AddShape
(
part
,
transform
,
rebuildMass
)
PhysicsShape
Add a shape from a physics hull
AddSphereShape
(
center
,
radius
,
rebuildMass
)
PhysicsShape
Add a sphere shape to this body.
ApplyAngularImpulse
(
impulse
)
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
(
force
)
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
(
position
,
force
)
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
(
impulse
)
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
(
position
,
velocity
)
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
(
force
)
Applies angular velocity to this body. This force will only be applied on the next physics frame and is scaled with physics timestep.
CheckOverlap
(
body
)
bool
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
(
vec
)
Vector3
Returns the closest point to the given one between all shapes of this body.
GetBounds
(
)
BBox
Returns Axis-Aligned Bounding Box (AABB) of this physics body.
GetGameObject
(
)
obsolete
GameObject
GetLerpedTransform
(
time
)
Transform
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
(
point
)
Vector3
Returns the world space velocity of a point of the object. This is useful for objects rotating around their own axis/origin.
LocalPoint
(
p
)
PhysicsPoint
Convenience function that returns a Sandbox.Physics.PhysicsPoint from a position relative to this body.
MassCenterPoint
(
)
PhysicsPoint
Returns a Sandbox.Physics.PhysicsPoint at the center of mass of this body.
Move
(
tx
,
delta
)
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
dynamic
bodies, rebuilds mass from all shapes of this body based on their volume and
physics properties
, for cases where they may have changed.
Remove
(
)
Completely removes this physics body.
ResetInertiaTensor
(
)
Resets the inertia tensor to its calculated values.
SetComponentSource
(
c
)
obsolete
SetInertiaTensor
(
inertia
,
rotation
)
Sets the inertia tensor using the given moments and rotation.
SmoothMove
(
position
,
timeToArrive
,
timeDelta
)
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
(
rotation
,
smoothTime
,
timeDelta
)
Rotate the body to this position in a way that cooperates with the physics system.
WorldPoint
(
p
)
PhysicsPoint
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.